Last post Sep 06, 2010 02:42 AM by dizruptor
Sep 02, 2010 04:44 AM|dizruptor|LINK
On the Default.aspx page the GridView control is populated programmatically by setting its Datasource to a list of table objects.
Is there some way I could populate this GridView manually using my own set of NavigateUrls and DisplayNames?
Sep 02, 2010 11:54 AM|boehmap|LINK
Yes. GridView can be bound to any IEnumerable, so if you were to put your url's and names in (for example) a Dictionary during Page_Init, you could make it your datasource in the aspx page. In the .aspx, change the navigate url to Key (or value, depending
on how you did it), and change the display name to however you stored your display name, and you should be good to go.
More information can be found here. GridView can be used on just about any page, not just DynamicData pages.
Sep 06, 2010 02:42 AM|dizruptor|LINK
Thanks for pointing me in the right direction Boehmap. Binding to a Dictionary object like you suggested works great.
Here's my aspx code for anyone who may be interested:
<asp:GridView ID="Menu1" runat="server" AutoGenerateColumns="false"
CssClass="DDGridView" RowStyle-CssClass="td" HeaderStyle-CssClass="HeaderStyle" CellPadding="6">
<asp:DynamicHyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("key") %>'><%# Eval("value") %></asp:DynamicHyperLink>