问题描述
任何人都可以帮我如何在C#中显示一行作为两列#
喜欢我的专栏是
>学习日期出勤
> 0001 01 P
> 0001 02 P
> 0001 03 P
> 0002 01 P
> 0002 02 P
> 0002 03 A
> ...... .. ...... ..
> 。
>
>我想显示这样的记录.......
>
>
> StudID date1 date2 date3 date4 date5 ...... ......
> 0001 P P P .. .. ...... ......
> 0002 P P A .. .. ...
> ...... ...... ...... ...... ......
can any one help me how to show a row as two columns in C#
Like My column is
> Studid date Attendance
> 0001 01 P
> 0001 02 P
> 0001 03 P
> 0002 01 P
> 0002 02 P
> 0002 03 A
> ... .. . ... ..
> .
>
> i want to display the record like this.......
>
>
> StudID date1 date2 date3 date4 date5 ... ... ...
> 0001 P P P .. .. ... ... ...
> 0002 P P A .. .. ...
> ... ... ... ... ... .. ... ... ...
推荐答案
protected void YourGridName_RowDataBound(object sender, DataGridItemEventArgs e)
{
int lastID=0
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Literal ltID = (Literal)e.Item.FindControl("Id");
int actualID= e.Item.DataItem.ID
if(actualID==lastID)
{
ltID.text=" ";
}
e.Item.CssClass = isAlternatingItem ? "alternating" : "";
lastID=actualID
}
}
创建一个新的css类在您的css文件中交替以区分网格的两个连续行
Create a new css class "alternating" at your css file to diffrentiate the two conseucative row of the grid
这篇关于如何在C#中将行显示为两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!