GridView记录编号和强行换行(学习笔记)
下面的代码写在RowDataBind函数里
编号和换行
获取标题栏的方法
编号和换行
if (e.Row.RowIndex > -1)
{
e.Row.Cells[0].Text = Convert.ToString(e.Row .RowIndex+1);
e.Row.Cells[2].Style.Add("work-break", "break-all");
}
{
e.Row.Cells[0].Text = Convert.ToString(e.Row .RowIndex+1);
e.Row.Cells[2].Style.Add("work-break", "break-all");
}
获取标题栏的方法
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 1; i < e.Row.Cells.Count; i++)
list.Add(e.Row.Cells[i].Text.ToString());
}
{
for (int i = 1; i < e.Row.Cells.Count; i++)
list.Add(e.Row.Cells[i].Text.ToString());
}