Fetch Data from datagrid and store them in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsunitadhn
    New Member
    • Jan 2008
    • 82

    Fetch Data from datagrid and store them in form

    I have a problem at the time of updating the datagrid. I want that at the time of update data is shown in form instead of datagrid.

    Code:
    Public Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
            GridView1.EditIndex = e.NewEditIndex
            Call LoadItems2() 'binding data to grid
    
            Dim id As Label = GridView1.Rows(e.NewEditIndex).Cells(1).FindControl("id".ToString())
            Dim compno As Label = GridView1.Rows(e.NewEditIndex).Cells(1).FindControl("CompNo")
            Dim compname As Label = GridView1.Rows(e.NewEditIndex).Cells(1).FindControl("CompName")
    
            lblid.Text = id.Text
            txt_CompNo.Text = compno.Text
            txt_CompName.Text = compname.Text
            btn_save.Enabled = True
    End Sub
    Last edited by Niheel; May 31 '10, 03:03 PM. Reason: application code posted, merged to question
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    What problem are you facing?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Typically you have a TemplateField with an EditItemTemplat e template specified within it. In the EditItemTemplat e you will have defined controls in order to retrieve data from the user.

      You use the GridViewRow.Fin dControl() method to retrieve the controls within the EditItemTemplat e when the user is updating.

      -Frinny

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Ok that's a nice piece of code.
        But....I think you want to handle the RowEdited event don't you? In that event you want to display the DateTime that the row was edited at?

        -Frinny

        Comment

        Working...