GridView行的序列号 [英] Serial number for GridView Rows
本文介绍了GridView行的序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的网格视图中有一个gridview,我可以随心所欲地显示数据。除了小点之外,这完全完成了。我想在第一列显示序列号。我知道如何提供序列号,但我需要以下格式。任何人都可以帮助我解决这个问题。
Hi everybody,
I have a gridview in my gridview i display the data whatever i want. That's totally completed except small point. I want to display serial numbers at first column. I know how to give serial number but i need in below format. Can any one help me out of this.
SNo Material Grade
1 RCC M30
1.a M50
1.c M70
2 FormWork column
2.a Plates
任何人都可以给我一些建议来实现我的系列以上格式的数字。
先谢谢
Can any one give me some suggestion to achieve my serial number in above format.
Thanks in Advance
推荐答案
这是一个可以帮助你的小功能
Here is a small function that might help you
private void generateSLNo(int totalRow)
{
List<string> li = new List<string>();
string s = string.Empty;
for (int i = 1; i <= 10; i++)
{
for (int j = 96; j < 123; j++)
{
if (j == 96)
{
s = s = Convert.ToString(i + ".");
}
else
{
s = Convert.ToString(i + "." + (char)j);
}
li.Add(s);
li.Add("<br>");
}
}
s = string.Empty;
for (int p = 0; p < li.Count; p++)
{
s = s + li[p].ToString();
}
lbl.Text = s;
}
你可以这样做
You can do this
<Columns>
<asp:CommandField ButtonType="Image" CancelImageUrl="~/data/commands/cancel.gif"
DeleteImageUrl="~/data/commands/delete.gif" DeleteText="Verwijder" EditImageUrl="~/data/commands/edit.gif"
EditText="Bewerk" SelectImageUrl="~/data/commands/download.gif" SelectText="Download bestand"
ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" UpdateImageUrl="~/data/commands/save.gif"
UpdateText="Opslaan">
<HeaderStyle Width="10%" />
</asp:CommandField>
<asp:BoundField HeaderText="No." ReadOnly="true">
<ItemStyle HorizontalAlign="Right" Width="1%" />
</asp:BoundField>
Then on the codebehing:
protected void gridLidDocument_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
e.Row.Cells[1].Text = "" + ((((GridView)sender).PageIndex * ((GridView)sender).PageSize) + (e.Row.RowIndex + 1));
}
这篇关于GridView行的序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文