Как отобразить данные представления сетки в текстовом поле всякий раз, когда пользователь нажимает на опцию редактирования в gridview
Моя регистрация.aspx-страницы
<div class="form-group" > ENTER EMPLOYEE ID : <asp:TextBox ID="TextBox1" placeholder="Employee ID" CssClass="form-control" width="400px" runat="server"></asp:TextBox> <br /> <br /> ENTER FIRSTNAME : <asp:TextBox ID="TextBox2" placeholder="First name" CssClass="form-control" width="400px" runat="server"></asp:TextBox> <br /> <br /> ENTER LASTNAME : <asp:TextBox ID="TextBox3" placeholder="Last name" CssClass="form-control" width="400px" runat="server"></asp:TextBox> <br /> <br /> ENTER ADDRESS: <asp:TextBox ID="TextBox4" placeholder="Address" CssClass="form-control" width="400px" runat="server"></asp:TextBox> <br /> <br /> <br /> ENTER CITY: <asp:TextBox ID="TextBox5" placeholder="city" CssClass="form-control" width="400px" runat="server"></asp:TextBox> <br /> <br /> <br /> <table> <tr> <td><asp:Button ID="Button1" runat="server" Text="Save" Width="70px" BackColor=" Lightblue" OnClick="Button1_Click"/></td> <td style="padding-left:20px;"></td> <td><asp:Button ID="Button2" runat="server" Text="Cancel" Width="60px" BackColor=" Lightblue" OnClick="Button2_Click" Height="26px"/></td> <td style="padding-left:20px;"></td> <%--<td> <asp:Button ID="Button4" runat="server" Text="Update" Width="60px" BackColor=" Lightblue" OnClick="Button4_Click" Height="27px"/></td>--%> </tr> </table> <br /> <br /> <%--Start--%> <table> <tr> <td> <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="EmpID" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" onrowcancelingedit="GridView3_RowCancelingEdit" onrowdeleting="GridView3_RowDeleting" onrowediting="GridView3_RowEditing" onrowupdating="GridView3_RowUpdating" CellSpacing="2" OnSelectedIndexChanged="GridView3_SelectedIndexChanged" onrowcommand="GridView3_RowCommand" > <Columns> <asp:TemplateField HeaderText="EmpID"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EmpID") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("EmpID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="FirstName"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="LastName"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("LastName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Address"> <EditItemTemplate> <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Bind("Address") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="City"> <EditItemTemplate> <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("City") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label5" runat="server" Text='<%# Bind("City") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns>
Если кто-нибудь может мне помочь
Что я уже пробовал:
И я попробовал это
protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e) { TextBox1.Text = gr.Cells[1].Text; TextBox2.Text = gr.Cells[2].Text; TextBox3.Text = gr.Cells[3].Text; TextBox4.Text = gr.Cells[4].Text; TextBox5.Text = gr.Cells[5].Text; } }