我想创建一个带有数据集的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