On Aug 19, 6:31 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thank you all very much for the replies. They came in very useful!
>
> One quick question for Sam, though. You said you don't use gridviews,
> etc... what do you do then? Manually write the tables?
I use a repeater and create a table, list, etc. That way I get it to
display exactly how I want, with the markup I want to send to the end
user. Much easier to style via CSS. I don't like how ASP.NET embeds
CSS within the HTML. So something like this:
<asp:Repeater ID="MyCategoriesRepeater" DataSource='<%#
MyCategories.DefaultView %>' OnItemCommand="CategoryMaintenance"
runat="server">
<HeaderTemplate>
<ul class="categories">
</HeaderTemplate>
<ItemTemplate><li><asp:TextBox ID="EditCategoryName" Text='<%#
DataBinder.Eval(Container.DataItem, "CategoryName") %>'
runat="server" />
<asp:Button ID="EditCategoryButton" runat="server" Text="Save
Category" CommandName="Edit" CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"CategoryID") %>' />
</li></ItemTemplate>
<FooterTemplate></ul>
Add Category: <asp:TextBox ID="NewCategoryName" runat="server" />
<asp:Button ID="NewCategoryButton" runat="server" Text="Add"
CommandName="Add" />
</FooterTemplate>
</asp:Repeater>
C#
protected void CategoryMaintenance(object sender,
RepeaterCommandEventArgs e)
{
switch (e.CommandName.ToString())
{
case "Add":
string categoryname =
((TextBox)e.Item.FindControl("NewCategoryName")).Text;
...
break;
case "Edit":
int categoryid = int.Parse(e.CommandArgument.ToString());
string categoryname =
((TextBox)e.Item.FindControl("NewCategoryName")).Text;
...
break;
default:
break;
}
}
I then also use 'CategoryMaintenance' for other repeaters (like a
nested one of sub categories). If I want to show more information,
then I can easily convert it to a table.