這裏是我的代碼爲什麼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