GridView (usersGrid):
<asp:ButtonField CommandName="Select" Text="Select" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID="changePasswordButton" Text="Change Password" OnClick="usersGrid_SelectRow" />
</ItemTemplate>
</asp:TemplateFild>
Code Behind:
protected void usersGrid_SelectRow(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent;
usersGrid.SelectedIndex = row.RowIndex;
MyDatabase.DBUtil = new MyDatabase.DBUtil();
changePasswordDetails.DataSource = DB.GetUser(Int16.Parse(usersGrid.SelectedValue.ToString());
changePasswordDetails.ChangeMode(DetailsViewMode.ReadOnly);
userDeatils.Visible = false;
changePasswordDetails.Visible = true;
changePasswordDetails.DataKeyNames = new string[] { "UserID" };
changePasswordDetails.DataBind();
}
No comments:
Post a Comment