Click here to Skip to main content
16,005,552 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi frnds,

am working on asp.net Gridview using c# and sqlserver 2005.

I want to display Gridview Selected row in label

Label is above the gridview.

Please help
THanks.
Posted
Updated 17-Sep-18 5:24am

 
Share this answer
 
C#
protected void OnSelectedIndexChanged(object sender, EventArgs e)
{
    string name = GridView1.SelectedRow.Cells[0].Text;
    string country = (GridView1.SelectedRow.FindControl("lblCountry") as Label).Text;

    lblValues.Text = "<b>Name:</b> " + name + " <b>Country:</b> " + country;
}
 
Share this answer
 
I am using this method

Label19.Text = GridView1.SelectedRow.Cells[1].Text;
Session("pass_id") = Label19.Text
Response.Redirect("admin_detaileddashboard.aspx")
 
Share this answer
 
 
Share this answer
 
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
GridView1.Rows[e.NewSelectedIndex].BackColor = System.Drawing.Color.Black;
string str = GridView1.Rows[e.NewSelectedIndex].Cells[5].Text;
Label8.Text = str.ToString();
}

when i try this code it shows label is empty or null
 
Share this answer
 
Comments
Richard Deeming 18-Sep-18 14:53pm    
If you want to ask a question, then ASK A QUESTION[^]. DO NOT post your question as a "solution" to someone else's question!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900