1
Posted on 4:58 AM by Softminer and filed under ,

  1.  <asp:BoundField DataField="ID" HeaderText="ID" >

  2.   </asp:BoundField>

  3. <asp:TemplateField HeaderText="ID" SortExpression="ID" >

  4.     <EditItemTemplate>

  5.         <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ID") %>'></asp:TextBox>

  6.     </EditItemTemplate>

  7.     <ItemTemplate>

  8.         <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label>

  9.     </ItemTemplate>

  10. </asp:TemplateField>

  11. <asp:TemplateField>

  12.     <ItemTemplate>

  13.         <asp:ImageButton ID="imgbutton" runat="server" CausesValidation="false" CommandName="Delete" ImageUrl="images.png" Text=""  CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ToolTip="delete file" />

  14.     </ItemTemplate>

  15. </asp:TemplateField>

  16. # in Code Behind

  17.  protected void Grid_RowCommand(object sender, GridViewCommandEventArgs e)

  18. {

  19.         if (e.CommandName == "Delete")

  20.         {

  21.             int rowIndex = Convert.ToInt32(e.CommandArgument);

  22.             GridViewRow row = (sender as GridView).Rows[rowIndex];

  23.             int Id = (int)Grid.DataKeys[row.RowIndex].Value;

  24.         }

  25. }

  26. protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)

  27.     {

  28.         if (e.Row.RowType == DataControlRowType.DataRow)

  29.         {

  30.             DataRowView rowView = (DataRowView)e.Row.DataItem;

  31.             ImageButton imgButton = (ImageButton)e.Row.Cells[1].Controls[1];

  32.         }

  33.     }

  34.              

1
Response to ... TemplateField & BoundField & Command Field in Gridview C# ASP.NET
oleg said... February 10, 2021 at 1:40 PM

How you need a casino right presently is only a major need. I think this will help you become a fruitful person who will consistently win large cash. In the event that you need more satisfaction, at that point in games you can get it. They will consistently reveal to you how to play accurately and river belle mobile casino how to put down wagers effectively in a casino