<asp:GridView ID="ListOfAvailableEvents_GrivView" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="10"> <Columns> <asp:TemplateField HeaderText="Title"> <ItemTemplate> <asp:LinkButton ID="lnkTitle" runat="server" Text='<%# Eval("Title") %>' OnClick="lnkTitle_Click"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" /> <asp:BoundField DataField="StartDateTime" HeaderText="Start Date & Time" SortExpression="StartDateTime" /> <asp:BoundField DataField="EndDateTime" HeaderText="End Date & Time" SortExpression="EndDateTime" /> </Columns> </asp:GridView>
protected void lnkTitle_Click(object sender, EventArgs e) { //to get the GridViewRow from the sender, so we can get the datakey we need //GridViewRow gvrow = (GridViewRow)((LinkButton)sender).Parent.NamingContainer; GridViewRow gvrow = (GridViewRow)(((LinkButton)sender)).NamingContainer; HiddenField1.Value = ListOfAvailableEvents_GrivView.DataKeys[gvrow.RowIndex].Value.ToString(); lblTitle.Text = gvrow.Cells[0].Text; lblDescription.Text = gvrow.Cells[1].Text; lblLocation.Text = gvrow.Cells[2].Text; lblStartDateTime.Text = gvrow.Cells[3].Text; lblEndDateTime.Text = gvrow.Cells[4].Text; //show the modalPopUp modalPopupExtender1.Show(); }
GridViewRow row=(GridViewRow)gridview1.row[e.rowindex]; LinkButton lb=(LinkButton)row.FindControl("linkbuttonname"); string str=lb.text;
LinkButton lnbTitle =(LinkButton) gvrow.FindControl("lnkTitle"); lblTitle.Text = lnbTitle.Text ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)