470,591 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Customizing the Datagrid or Repeater

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.

--
J. D.
Nov 19 '05 #1
1 1406
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>
"JD" wrote:
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.

--
J. D.

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Job Lot | last post: by
2 posts views Thread by Stephen Miller | last post: by
7 posts views Thread by Scott Schluer | last post: by
2 posts views Thread by News | last post: by
3 posts views Thread by Maziar Aflatoun | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.