jbaisden
asked on
Creating Tables inside of datagrid / repeater with rows that span columns
Currently I am using a repeater control with paging that I implemented myself. Because the result set can be somewhat large and I'm storing the entire result in view state, the paging is going extremely slow.
My basic need is a control that displays records in the format below, but also has some kind of paging. I have thought about the datagrid but I don't know if this is within its ability.
Col 1 | Col 2 | Col 3
data data data
Message data that spans all columns
Field data that spans all columns
Value data that spans all columns
I have this effect achieved with the Repeater, but as I said, it's slow. The important factors in this scenerio are that the four rows displayed above represent a single record from the database. Another factor is that, there are some cases where I don't want the Message, Field, and Value rows to be displayed at all, but rather I want them to be hidden.
I would prefer to use the datagrid because it has its own paging; however, I haven't seen any examples for something like this with the datagrid.
My current plan is to shift from storing things in viewstate to the session so the server can handle it and I'll just have to force the session to clear manually.
I'm out of idea's here and anything any of you can think of will really help. Thanks!
ASKER
The problem with using a template column is that it represents 1 column. This means I have only 1 headerText property, but in reality, I need 4. If I manually add the headers to the actual template column then they will repeat for every record and this is not desired.
then you have find in which circuminstances you want merge columns, like on what basis as then you have to do it programatically through code. like
e.Item.Cells(0).Attributes .Add("cols pan","4")
e.Item.Cells(0).Attributes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
e.g. , you have total 4 column ,and want to span 4th row then following code will work:
-In databound column
i
if (e.Item.ItemIndex==3)
{
e.Item.Cells[0].ColumnSpan =4;
e.Item.Cells[0].Horizontal Align=Hori zontalAlig n.Center;
e.Item.Cells[1].Visible=fa lse;
e.Item.Cells[2].Visible=fa lse;
e.Item.Cells[3].Visible=fa lse;
}
hope it will work for u
-In databound column
i
if (e.Item.ItemIndex==3)
{
e.Item.Cells[0].ColumnSpan
e.Item.Cells[0].Horizontal
e.Item.Cells[1].Visible=fa
e.Item.Cells[2].Visible=fa
e.Item.Cells[3].Visible=fa
}
hope it will work for u
ASKER
I have this figured out for the most part. Thanks for your help.
ASKER
I will post the details later.
<asp:TemplateColumn HeaderText="test">
<ItemTemplate>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR> <TD>column containing your data e.g. <%#DataBinder.Eval(Contain
<TD></TD>
<TD></TD>
</TR>
<TR> <TD colSpan="2"></TD>
<TD>gfj</TD>
</TR> </TABLE>
</ItemTemplate>
</asp:TemplateColumn>