Sir,
I am in a ASP.NET project. I stuck in code piece to fetch GridView cell value into a variable. Data being fetched from database in page load(if !PostBack). then all cell value become null when come to the RowCommand event. why that happening?
Here the code:-
int EmpID = Convert.ToInt32(((GridViewRow)(((LinkButton)e.CommandSource).NamingContainer)).Cells[1].Text);


Karthik ElumalaiRank #544 · 4.5K reputationPosted Jun 17, 2016, 6:52 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Jun 18, 2016, 4:03 AM EDT
// Get the currently selected row using the SelectedRow property. GridViewRow row = dgCustomer.SelectedRow; // And you respective cell's value TextBox1.Text = row.Cells[1].Text