locked
How to update row in gridview using the AutoGenerateEditButton RRS feed

  • Question

  • Hi, I've been trying to use the AutoGenerateEditButton to edit a simple row in the gridview but the problem is that I cannot manage to find a way of getting the new value and change to the old one.

    All the example that I found on the web were using textboxes to compare the values and than edit the row but my problem is that when I use the AutoGenerateEditButton I creates the textbox by itself, so it has no ID reference for me to compare,here's the code:

     

    <asp:GridView ID="GridView1" runat="server" 

                        Height="16px" Width="609px" HorizontalAlign="Center" HeaderStyle-BackColor="Gray" 

                        onselectedindexchanged="GridView1_SelectedIndexChanged" 

                            onrowediting="GridView1_RowEditing" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" 

                            onrowcancelingedit="GridView1_RowCancelingEdit" 

                            onrowdeleting="GridView1_RowDeleting" onrowupdating="GridView1_RowUpdating">

                        <RowStyle HorizontalAlign="Center" />

                        <HeaderStyle BackColor="Gray" />

                        <EditRowStyle HorizontalAlign="Center" />

                    </asp:GridView>

     

    I'm filling the gridview information from a datatable:

     

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            DataTable dados = loadData.activeDate(ListBox1.SelectedValue);

            GridView1.DataSource = dados;

            GridView1.DataBind();

            ListBox1.Focus();

        }

     

    What I'm trying to do is to get the new value from the gridview, save it into variable and than save the new value into the old datatable. If I manage to do that I'll be able the read the information from the already modified datatable and filling the gridview again, with the new information.

    Could anyone help how to do that??

     

    regards.

     

     

     

     

    • Moved by Cookie Luo Monday, April 18, 2011 2:05 AM (From:Visual C# General)
    Thursday, April 14, 2011 8:06 PM

All replies

  • Hi

    Please try asp.net forum for better support. Asp.net issue is not supported here.


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 18, 2011 2:05 AM
  • Cookie Luo, I need your help deleting my threads on my account, is there an email or phone number where I can talk to a moderator and explain the situation on why I wanna to that?

    Friday, September 12, 2014 3:23 PM