Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code Behind:
- protected void gvCustomers_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName.Equals("RowSelected"))
- {
- GridViewRow row = (((e.CommandSource) as Button).NamingContainer) as GridViewRow;
- Label label = row.FindControl("lblFirstName") as Label;
- Response.Write(label.Text);
- }
- }
- <asp:GridView AutoGenerateColumns="false" ID="gvCustomers" runat="server" OnRowCommand="gvCustomers_RowCommand" >
- <Columns>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:Label ID="lblFirstName" runat="server" Text ='<%# Eval("FirstName") %>' />
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:Button Text="Select" ID="btn1" runat="server" CommandArgument ='<%# Eval("FirstName") %>' CommandName="RowSelected" />
- </ItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
- <asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"OnRowCommand="gvProduct_RowCommand" >
- <Columns>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:ImageButton ID="btnEdit" runat="server" CommandName="EditCommand" Text="Edit" />
- </ItemTemplate>
- </asp:TemplateField>
- <asp:BoundField DataField="ProjectNo" HeaderText="ProjectNo" />
- <asp:BoundField DataField="Date" HeaderText="Date" />
- <asp:BoundField DataField="Shift" HeaderText="شیفت" />
- </Columns>
- </asp:GridView>
- protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- if (e.CommandName == "EditCommand")
- {
- GridViewRow Row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
- int productID = Convert.ToInt32(gvProduct.DataKeys[Row.RowIndex].Value);
- EditFunction(productID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement