WeebMaster3957
New Member
I have a \[code\]GridView\[/code\], to which I have written a DataBound function to assign a tooltip. But it is not getting assigned. The function I have written is:\[code\]SqlCommand comd = new SqlCommand("SELECT Location_Profile_Name, " + Label10.Text + " as Home_Profile FROM Home_Profile_Master", con); SqlDataAdapter da = new SqlDataAdapter(comd); DataTable dt = new DataTable(); da.Fill(dt); GridView3.DataSource = dt; GridView3.DataBind();protected void GridView3_DataBound(object sender, EventArgs e) { var gv = (GridView)sender; foreach (GridViewRow row in GridView3.Rows) { string label2 = row.Cells[2].Text.Trim(); if (label2.Length != 0) { con.Open(); string str = "SELECT Location_Profile_Tool_Tip FROM Location_Profile_List_ToolTip WHERE Location_Profile_Name='" + label2 + "'"; SqlCommand cmd = new SqlCommand(str, con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { row.Cells[2].ToolTip = dr[0].ToString().Trim(); } con.Close(); } } }\[/code\]When I debug the label2 is null. The same code is executing for another Grid. What is wrong...!! Kindly help..!