这里是我的代码为什么e.Row.Cells [2]。文本总是显示“”或GridView1_RowDataBound事件空
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;
}
}
}
但Convert.ToString(e.Row.Cells[2].Text);
这里总是给我“”。我的代码有什么问题吗?
感谢您的帮助,但这里列colu mnname和在我的代码中,我如何获得该循环中的特定单元格的列名 – Raj 2013-03-08 05:55:09
使用:((DataBoundLiteralControl)e.Row.Cells [7] .Controls [0])。 – 2013-03-08 06:04:16
对不起,但它没有工作是否有任何其他找到循环中的单元格文本值e.row.cells.count – Raj 2013-03-08 06:14:04