Hello.
I am wondering how I can edit a selected row (by a link button) by showing the cell values in textboxes.
I have this code so far.
ASP.NET
-----------------
-----------------
C# Code Behind
------------
And can someone explain to me what this line of code can do? plss make it specific, I cant understand the .Parent.Parent
using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)
i just found this on the internet..
Any help would be so much appreciated.
Thanks and have a nice day!
ASP.NET
-----------------
| Leave Type | Application Date |
CellPadding="4" ForeColor="#333333" EmptyDataText= "No current record found in the database." Width="868px" OnRowCommand="GridViewRowCommand"><%--OnRowDeleting="EmpLeaveAppGV1_SelectedIndexChanged"--%>
C# Code Behind
------------
protected void GridViewRowCommand(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName=="EditPending")
{
int LeaveTranID = Convert.ToInt32(e.CommandArgument);
int rowindex = EmpLeaveAppGV1.SelectedIndex;
Label lblLeaveType = (Label)(EmpLeaveAppGV1).Rows[rowindex].FindControl("lblLeaveType");
txtLeaveType.Text = lblLeaveType.Text;
div1.Visible = true;
}
}
------------And can someone explain to me what this line of code can do? plss make it specific, I cant understand the .Parent.Parent
using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)
i just found this on the internet..
Any help would be so much appreciated.
Thanks and have a nice day!
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Apr 1, 2014, 2:59 AM
http://www.c-sharpcorner.com/uploadfile/syedshakeer/how-to-get-the-values-of-selected-row-from-a-gridview-using-Asp-Net/