哦,是自动生成的,你的数据是用什么来显示的,如果是DATAGRID,前面可加一列,设为只读
在DATAGRID的ITEMDATABOUND里面
if e.item.itemindex>=0 then
e.item.cell(0).text=e.item.itemindex+1'假设在第一列
end if
在DATAGRID的ITEMDATABOUND里面
if e.item.itemindex>=0 then
e.item.cell(0).text=e.item.itemindex+1'假设在第一列
end if
我在datagrid中已加了一列,接下来就不知了,在线等候,十分感谢
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemIndex >= 0)
{
int i = DataGrid1.CurrentPageIndex * DataGrid1.PageSize + e.Item.ItemIndex + 1;
e.Item.Cells[0].Text = i.ToString();
}
}Cells[0]是指在第一列插入序号