How to place data into textboxes from datagrid using editcommandname?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kolags
    New Member
    • Oct 2007
    • 9

    How to place data into textboxes from datagrid using editcommandname?

    Hi all,
    Please give me guidance to complete this task.

    As per my requirement, I want to place data in to different textboxes whatever I selected from datagrid using edit command name.
    Means I need to Binding Database Data into Textboxes whenever I click on the edit button at the end of the each row in datagrid, the data in each cell of the selected row has to be place in different textboxes.
    How to solve this issue?

    Thanks in Adv.
    kolags@hotmail. com
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by Kolags
    Hi all,
    Please give me guidance to complete this task.

    As per my requirement, I want to place data in to different textboxes whatever I selected from datagrid using edit command name.
    Means I need to Binding Database Data into Textboxes whenever I click on the edit button at the end of the each row in datagrid, the data in each cell of the selected row has to be place in different textboxes.
    How to solve this issue?

    Thanks in Adv.
    kolags@hotmail. com
    what is your language?? working platform?? project type???
    vb/c#.........???? windows/web.....??.net2 003/.net2005...???

    Comment

    • Kolags
      New Member
      • Oct 2007
      • 9

      #3
      In VS-2003 ASP.Net using VB.net.

      Comment

      • dip_developer
        Recognized Expert Contributor
        • Aug 2006
        • 648

        #4
        Originally posted by Kolags
        In VS-2003 ASP.Net using VB.net.
        The DataGrid contains a property called EditItemIndex, which specifies what row of the DataGrid is the
        row being edited. The DataGrid numbers its rows starting at 0. By default, the DataGrid is not editing any
        row, so the EditItemIndex, by default, has a value of -1. Since we want to mark a row for editing when its "Edit"
        button is clicked, we simply need to write some code in the EditCommand event handler, which is the DataGrid
        event handler that is fired when the EditCommandColu mn control's "Edit" button is clicked. This event handler
        simply needs to set the EditItemIndex property to the row whose "Edit" button was clicked and then rebind the
        DataGrid data (by calling BindData() or your chosen function name). The code for this event handler can be seen below:

        [CODE=vbnet]
        Sub dgProducts_Edit (sender As Object, e As DataGridCommand EventArgs)
        dgProducts.Edit ItemIndex = e.Item.ItemInde x
        BindData()
        End Sub
        [/CODE]

        To wire this event handler up to the EditCommand event, simply specify this in your DataGrid control, like so:

        [CODE=HTML]
        <asp:DataGrid id="dgProducts " runat="server"
        ...
        OnEditCommand=" dgProducts_Edit "
        ... >

        <Columns>
        ...
        </Columns>
        </asp:DataGrid>
        [/CODE]

        hope it helps...

        Comment

        • Kolags
          New Member
          • Oct 2007
          • 9

          #5
          Hi,

          Thanks alot for your guidence.
          Now I have another doubt, I have a check box in my datagrid. As per our requirement, data which is selected by check box should populate in to text boxes. I am able to bind by using edit button, but now I am unable to fire the check box checked event.

          It is like general mail system, In our mail inbox we do have a check box, once selected few check boxes we can easily deleting the selected mail by hitting Delete button.
          Please suggest how to fire the check box checked event. It's very urgent.

          Comment

          • Kolags
            New Member
            • Oct 2007
            • 9

            #6
            Hi all,
            I have completed my task using the following code for placing data (Data Binding), which is in datagrid. By clicking edit button on the datagrid at the starting column.

            Textbox1.text=d atagrid.Selecte dItem.Cells(1). Text
            Then immediately the corresponding data in the datagrid has to populate into textbox.

            And the following code can be used for the Second Request (check box type).

            Dim DemoGridItem As DataGridItem
            For Each DemoGridItem In datagrid.Items
            Dim myCheckbox As CheckBox = CType(DemoGridI tem.Cells(0).Co ntrols(1), CheckBox)
            If myCheckbox.Chec ked = True Then
            rowCount += 1
            textbox1.text=" ,", DemoGridItem.Ce lls(0).Text

            End If

            Comment

            Working...