Click here to Skip to main content
13,795,369 members
Rate this:
 
Please Sign up or sign in to 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 17-Feb-14 0:38am
Updated 17-Sep-18 6:24am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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;
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

I am using this method

Label19.Text = GridView1.SelectedRow.Cells[1].Text;
Session("pass_id") = Label19.Text
Response.Redirect("admin_detaileddashboard.aspx")
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

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
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.181207.3 | Last Updated 17 Sep 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100