Click here to Skip to main content
15,881,172 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Loop DataTable per assegnare valori alle rows non ci riesco Pin
Fabrizio Leoncini21-Aug-20 21:31
Fabrizio Leoncini21-Aug-20 21:31 
GeneralRe: Loop DataTable per assegnare valori alle rows non ci riesco Pin
Eddy Vluggen22-Aug-20 10:01
professionalEddy Vluggen22-Aug-20 10:01 
GeneralRe: Loop DataTable per assegnare valori alle rows non ci riesco Pin
CHill6025-Aug-20 2:17
mveCHill6025-Aug-20 2:17 
GeneralRe: Loop DataTable per assegnare valori alle rows non ci riesco Pin
Eddy Vluggen25-Aug-20 15:19
professionalEddy Vluggen25-Aug-20 15:19 
QuestionExcel vba creating a timer through doevents Pin
Mat 25720-Aug-20 3:42
Mat 25720-Aug-20 3:42 
AnswerRe: Excel vba creating a timer through doevents Pin
Dave Kreskowiak20-Aug-20 4:31
mveDave Kreskowiak20-Aug-20 4:31 
GeneralRe: Excel vba creating a timer through doevents Pin
Mat 25720-Aug-20 10:22
Mat 25720-Aug-20 10:22 
QuestionGridview RowUpdating not showing updated record in grid Pin
cmn219-Aug-20 2:58
cmn219-Aug-20 2:58 
I have applied sorting to the columns of a gridview and it works fine. There is a command field ShowEditButton to allow the user to update a record. In the code behind, the RowEditing and RowCancelingEdit also work as intended. The problem is the RowUpdating event. When the event fires the row in the database does get updated, but the gridview continues to show the previous value. The page actually has to unload and reload to show the new value. If anyone has any idea how to overcome this issue it sure would be appreciated.

Gridview:

<asp:GridView ID="grdSeries" runat="server" AutoGenerateColumns="False" DataKeyNames="SeriesChrCode, ProductLine, ProcurementType" AllowSorting="true">
                                 <Columns>
                                    <asp:CommandField  ShowEditButton="True" CausesValidation="False"/>   
                                    <asp:BoundField HeaderText="SeriesChrCode" ReadOnly="True"  Visible="False" DataField="SeriesChrCode"/>
                                    <asp:BoundField HeaderText="ProductLine" ReadOnly="True"  Visible="False" DataField="ProductLine"/>
                                    <asp:BoundField HeaderText="ProcurementType" ReadOnly="True"  Visible="False" DataField="ProcurementType"/>
                                                                     

                                    <asp:TemplateField HeaderText="Character Code" ItemStyle-HorizontalAlign="Center" SortExpression="SeriesChrCode">
                                        <ItemTemplate><asp:Label ID="lblSeriesChrCode" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SeriesChrCode") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                        <asp:TextBox runat="server" ID="edit_SeriesChrCode" MaxLength="15" Text='<%#Bind(Container.DataItem, "SeriesChrCode") %>' />
                                        </EditItemTemplate>
                                    </asp:TemplateField>  

                                    <asp:TemplateField HeaderText="ProductLine" ItemStyle-HorizontalAlign="Center" SortExpression="ProductLine">
                                        <ItemTemplate><asp:Label ID="lblProductLine" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ProductLine") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                        <asp:DropDownList runat="server" ID="edit_ProductLine"  selectedvalue='<%#Bind(Container.DataItem, "ProductLine") %>' DataTextField="ProductLine"  DataValueField="ProductLine"  datasource ='<%# GetProductLines %>' />
                                        </EditItemTemplate>
                                    </asp:TemplateField>
                    
                                    <asp:TemplateField HeaderText="ProcurementType" ItemStyle-HorizontalAlign="Center" SortExpression ="ProcurementType">
                                        <ItemTemplate><asp:Label ID="lblProcurementType" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ProcurementType") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                        <asp:DropDownList runat="server" ID="edit_ProcurementType"  selectedvalue='<%#Bind(Container.DataItem, "ProcurementType") %>' DataTextField="ProcurementType"  DataValueField="ProcurementType"  datasource ='<%# GetProcurementTypes %>' />
                                        </EditItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField HeaderText="Series Code Description" ItemStyle-HorizontalAlign="Center" SortExpression ="SeriesCodeDescription">
                                        <ItemTemplate><asp:Label ID="lblSeriesCodeDescription" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SeriesCodeDescription") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                        <asp:TextBox runat="server" ID="edit_SeriesCodeDescription" MaxLength="50" Text='<%#Bind(Container.DataItem, "SeriesCodeDescription") %>' />
                                        </EditItemTemplate>
                                    </asp:TemplateField>                               

                                </Columns>
                            </asp:GridView>


RowEditing and RowCancelEdit subs (both work):

Private Sub grdSeries_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles grdSeries.RowCancelingEdit

        grdSeries.EditIndex = -1

        Dim o As New clsData
        Dim dt As DataTable = o.GetSeries
        grdSeries.DataSource = dt
        grdSeries.DataBind()

        '************* 
       'works fine

        If Not IsNothing(Session("LastSort")) Then
            Dim dv As DataView = Session("LastSort")
            grdSeries.DataSource = dv
            grdSeries.DataBind()
        End If

    End Sub

    Private Sub grdSeries_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles grdSeries.RowEditing

        grdSeries.EditIndex = CInt(e.NewEditIndex)

        Dim o As New clsData
        Dim dt As DataTable = o.GetSeries
        grdSeries.DataSource = dt
        grdSeries.DataBind()

        '*************
        'works fine

        If Not IsNothing(Session("LastSort")) Then
            Dim dv As DataView = Session("LastSort")
            grdSeries.DataSource = dv
            grdSeries.DataBind()
        End If

    End Sub



RowUpdating (not rendering in grid):

Private Sub grdSeries_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles grdSeries.RowUpdating

        Dim o As New clsData

        'get the id of the row being updated
        'product line and procurementtype are updateable
        'they are also the primary key
        Dim strSeriesChrCode As String = grdSeries.DataKeys(e.RowIndex).Values("SeriesChrCode")
        Dim strProductLine As String = grdSeries.DataKeys(e.RowIndex).Values("ProductLine")
        Dim strProcurementType As String = grdSeries.DataKeys(e.RowIndex).Values("ProcurementType")

        Dim cntrl_0 As TextBox
        cntrl_0 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_SeriesChrCode"), TextBox)
        Dim strCntrl_0 As String = cntrl_0.Text

        Dim cntrl_1 As DropDownList
        cntrl_1 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_ProductLine"), DropDownList)
        Dim strCntrl_1 As String = cntrl_1.Text

        Dim cntrl_2 As DropDownList
        cntrl_2 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_ProcurementType"), DropDownList)
        Dim strCntrl_2 As String = cntrl_2.Text

        Dim cntrl_3 As TextBox
        cntrl_3 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_SeriesCodeDescription"), TextBox)
        Dim strCntrl_3 As String = cntrl_3.Text


        Dim b As Boolean = o.UpdateSeries(strCntrl_0, strCntrl_1, strCntrl_2, strCntrl_3, strSeriesChrCode, strProductLine, strProcurementType)

       
        grdSeries.EditIndex = -1

      
        '*******************
       
        'sort order is ok and data is updated on backend but does not show on the front end

           Dim dt As DataTable = o.GetSeries
            grdSeries.DataSource = dt
            grdSeries.DataBind()

        If Not IsNothing(Session("LastSort")) Then           

            Dim dv As DataView = Session("LastSort")
            grdSeries.DataSource = dv
            grdSeries.DataBind()

        End If

    End Sub

AnswerRe: Gridview RowUpdating not showing updated record in grid Pin
Eddy Vluggen22-Aug-20 10:03
professionalEddy Vluggen22-Aug-20 10:03 
QuestionNArrange Pin
ChrisRaisin13-Aug-20 14:52
ChrisRaisin13-Aug-20 14:52 
AnswerRe: NArrange Pin
Dave Kreskowiak13-Aug-20 16:33
mveDave Kreskowiak13-Aug-20 16:33 
QuestionHow code to Print a Bit map image to pos printer via comport in VB6 Pin
Member 149097158-Aug-20 0:25
Member 149097158-Aug-20 0:25 
AnswerRe: How code to Print a Bit map image to pos printer via comport in VB6 Pin
Richard MacCutchan8-Aug-20 0:46
mveRichard MacCutchan8-Aug-20 0:46 
AnswerRe: How code to Print a Bit map image to pos printer via comport in VB6 Pin
Eddy Vluggen22-Aug-20 10:07
professionalEddy Vluggen22-Aug-20 10:07 
QuestionGeoreferencing Pin
Benniit7-Aug-20 20:50
Benniit7-Aug-20 20:50 
AnswerRe: Georeferencing Pin
OriginalGriff7-Aug-20 20:51
mveOriginalGriff7-Aug-20 20:51 
AnswerRe: Georeferencing Pin
Richard MacCutchan7-Aug-20 21:51
mveRichard MacCutchan7-Aug-20 21:51 
AnswerRe: Georeferencing Pin
Eddy Vluggen22-Aug-20 10:09
professionalEddy Vluggen22-Aug-20 10:09 
QuestionFile System Watcher for remote folders? Pin
ForeverSoftware6-Aug-20 3:47
ForeverSoftware6-Aug-20 3:47 
AnswerRe: File System Watcher for remote folders? Pin
Richard Deeming6-Aug-20 4:00
mveRichard Deeming6-Aug-20 4:00 
QuestionRunning VBA in Shared Mailboxes 365 Pin
Willie_n5-Aug-20 23:20
Willie_n5-Aug-20 23:20 
AnswerRe: Running VBA in Shared Mailboxes 365 Pin
CHill6014-Aug-20 1:38
mveCHill6014-Aug-20 1:38 
QuestionBizarre problem with VBA in an Access Form Pin
Peter R. Fletcher16-Jul-20 12:03
Peter R. Fletcher16-Jul-20 12:03 
AnswerRe: Bizarre problem with VBA in an Access Form Pin
CHill6020-Jul-20 5:30
mveCHill6020-Jul-20 5:30 
AnswerRe: Bizarre problem with VBA in an Access Form Pin
CHill6020-Jul-20 5:44
mveCHill6020-Jul-20 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.