我想創建一個帶有數據集的gridview,我在數據綁定之後隱藏了一些列。我還需要顯示Descriptin列的前50個字符。我怎樣才能做到這一點?這裏是我的代碼在gridview中顯示數據集單元格的子串
protected void grid_all_posts_DataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
e.Row.Cells[1].Visible = false;
// I want to display only substring in Gridview
e.Row.Cells[3].Text = e.Row.Cells[3].Text.ToString().Substring(0,50);
}
我希望這是明確
你有什麼問題? – 2013-02-11 18:37:44
對不起。它給出這個錯誤「System.ArgumentOutOfRangeException:索引和長度必須引用字符串中的位置。」 – 2013-02-11 18:39:02