Customizing the Datagrid or Repeater

  • Thread starter Thread starter JD
  • Start date Start date
J

JD

Hello Everyone,

I am trying to do a page where when the user gets to the page it will look
very similar to the following:

<table border=1>
<tr>
<td bgcolor="green" colspan="2">Main Header</td>
</tr>
<tr><td bgcolor="gray">SubHead1</td><td bgcolor="gray">Subhead2 -
Delete</td></tr>
<tr><td>data</td><td><a href="">delete record</a></td></tr>
<tr><td colspan=2></td></tr>
<tr><td colspan=2><a href="">Add New Row</a></td></tr>

</table>


I was originally planning to do this with the repeater control, but I am not
too sure how I can add rows to the repeater dynamically, so that a user
would be able to edit the data (under Subhead1 column). So I thought about
using the datagrid, but I am not too sure on how I would get the datagrid to
display the Main header and subheader colums the way I have it laid out
above. So I was hoping someone would be able to help out and let me know if
this is possible and if so how would one go about doing it....whether it is
with the repeater control or the datagrid control, and hopefully this is
something that can be done in vb.net as I am not too familiar with c#.
Thanks.
 
The easiest approach would be a repeater, or datalist if you need for
functionality (pagination, etc.)

Use the HeaderTemplate and the ItemTemplates to create your layout and use
labels and link buttons that you need. These controls can be set in the
repeater's itemdatabound event.

Repeaters do not generate any structure, it is up to you to do so.
DataGrids are much more difficult to customize.

<asp:Repeater id=Repeater1 runat="server">
<HeaderTemplate>
<table>
<tr>
<td bgcolor="green" colspan="2">Main Header</td>
</tr>
<tr><td bgcolor="gray">SubHead1</td><td bgcolor="gray">Subhead2 -
Delete</td></tr>

</HeaderTemplate>
<ItemTemplate>
<tr><td>
<asp:label ID=data Runat=server></asp:label></td><td>
<asp:LinkButton ID=delete Runat=server>Delete</asp:LinkButton></td></tr>
<tr><td colspan=2></td></tr>
<tr><td colspan=2><asp:LinkButton id=LinkButton1 runat="server">Add New
Row</asp:LinkButton></td></tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
 
Back
Top