Why e.Row.Cells[2].Text always show "" or null in GridView1_RowDataBound event
asp.net, c#, gridview
Solution
Please use this code
var ToolTipString = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Column"));
Problem
Here is my code ``` protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // DataRow data = ((DataRowView)e.Row.DataItem).Row; string ToolTipString = Convert.ToString(e.Row.Cells[2].Text); e.Row.Cells[2].Attributes.Add("title", ToolTipString); Label MyLabel = (Label)e.Row.FindControl("MyLabel"); if (ToolTipString.Length < 20) { MyLabel.Text = ToolTipString; } else { MyLabel.Text = String.Format("{0}...", ToolTipString.Substring(0, 17)); MyLabel.ToolTip = ToolTipString; } } } ``` But `Convert.ToString(e.Row.Cells[2].Text);` here always gives me "". Is there anything wrong in my code?