The grid:
Expand|Select|Wrap|Line Numbers
- <asp:GridView ID="dg1" runat="server" CssClass="GridBorder" HeaderStyle-CssClass="THGRID"
- DataKeyNames="code" AutoGenerateColumns="false" CellPadding="3"
- Font-Size="8pt" GridLines="Both" Showfooter="false"
- PageSize="10" PagerSettings-PageButtonCount="15" PagerSettings-Mode="NextPreviousFirstLast"
- BorderWidth="1px" BorderStyle="Solid" BorderColor="black"
- OnRowEditing="dg1_OnRowEditing"
- OnRowCancelingEdit="dg1_RowCancelingEdit"
- OnRowUpdating="dg1_RowUpdating">
- <Columns>
- <asp:CommandField ShowEditButton="True" />
- <asp:CommandField ShowDeleteButton="True" />
- <asp:BoundField DataField="code" HeaderText="Code" readonly="true" />
- <asp:TemplateField HeaderText="Name">
- <ItemTemplate>
- <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'> </asp:Label> </ItemTemplate>
- <EditItemTemplate> <asp:textbox ID="txtName" runat="server" Width="250px"
- * * * * * Text='<%# Bind("Name")%>'> </asp:textbox>
- </EditItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
Expand|Select|Wrap|Line Numbers
- protected void dg1_RowUpdating(Object sender, GridViewUpdateEventArgs e)
- {
- int i = dg1.Rows[e.RowIndex].DataItemIndex;
- TextBox txtName = dg1.Rows[e.RowIndex].Cells[2].FindControl("txtName") as TextBox;
- string newname = txtName.Text;
Ken