Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. Code Behind:
  2.  
  3. protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
  4. {
  5. if (e.CommandName.Equals("RowSelected"))
  6. {
  7. GridViewRow row = (((e.CommandSource) as Button).NamingContainer) as GridViewRow;
  8. Label label = row.FindControl("lblFirstName") as Label;
  9.  
  10. Response.Write(label.Text);
  11.  
  12. }
  13. }
  14.  
  15. <asp:GridView AutoGenerateColumns="false" ID="gvCustomers" runat="server" OnRowCommand="gvCustomers_RowCommand" >
  16.  
  17. <Columns>
  18.  
  19. <asp:TemplateField>
  20. <ItemTemplate>
  21.  
  22. <asp:Label ID="lblFirstName" runat="server" Text ='<%# Eval("FirstName") %>' />
  23.  
  24. </ItemTemplate>
  25. </asp:TemplateField>
  26.  
  27. <asp:TemplateField>
  28. <ItemTemplate>
  29. <asp:Button Text="Select" ID="btn1" runat="server" CommandArgument ='<%# Eval("FirstName") %>' CommandName="RowSelected" />
  30. </ItemTemplate>
  31. </asp:TemplateField>
  32.  
  33. </Columns>
  34.  
  35. </asp:GridView>
  36.  
  37. <asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"OnRowCommand="gvProduct_RowCommand" >
  38. <Columns>
  39. <asp:TemplateField>
  40. <ItemTemplate>
  41. <asp:ImageButton ID="btnEdit" runat="server" CommandName="EditCommand" Text="Edit" />
  42. </ItemTemplate>
  43. </asp:TemplateField>
  44. <asp:BoundField DataField="ProjectNo" HeaderText="ProjectNo" />
  45. <asp:BoundField DataField="Date" HeaderText="Date" />
  46. <asp:BoundField DataField="Shift" HeaderText="شیفت" />
  47. </Columns>
  48. </asp:GridView>
  49.  
  50. protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
  51. {
  52. if (e.CommandName == "EditCommand")
  53. {
  54. GridViewRow Row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
  55. int productID = Convert.ToInt32(gvProduct.DataKeys[Row.RowIndex].Value);
  56.  
  57. EditFunction(productID);
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement