GridView SelectedValue via LinkButton on Select
I usualy just use the default 'Select' on my Data Grids, but now, I need
to popup a Modal Popup when the user selects a row. So, I am trying to use
an ImageButton:
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="imgbtn"
ImageUrl="../Images/edit.png" runat="server"
Width="25" Height="25" OnClick="edit_Click"
CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Project
Name" />
<asp:BoundField DataField="ProjectCode"
HeaderText="Code" />
<asp:TemplateField
HeaderText="Access"></asp:TemplateField>
</Columns>
I created the OnClick event, which fires, and I thought that I can maybe
get the selectedvalue of the row in that event. I usually used
GridView1_SelectedIndexChanged event.
But I am battling to find a way to get the SelectedValue.
protected void edit_Click(object sender, ImageClickEventArgs e)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
Session["SelectedUserProjectId"] = ???? // This is where I am trying
to get the selected value - but can't find a way to do so.
var pi = int.Parse(Session["SelectedUserProjectId"].ToString());
var ui = int.Parse(Session["SelectedUserId"].ToString());
// Do some calls to get data, populate fields, and then...
this.pnlEdit_ModalPopupExtender.Show();
}
Can anyone guide me on how to get the selected value of the GridView?
No comments:
Post a Comment