How to create a datagrid on the fly ?

C

chak

Hi,

Any examples / pointers on how to render a datagrid on the fly in a asp.net
page, based on dynamic parameters ?

Thanks.
 
T

Teemu Keiski

Creating dynamically:
http://www.dotnetbips.com/displayarticle.aspx?id=66

More dg articles @ www.datagridgirl.com/articles.aspx

Perhaps you meant creating on the fly? I don't see any benefits rendering it
on-the-flya s it is rendered if dg just is part of Controls collection on
the Page.

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
 
D

Dave

Excellent reference site!
The reason why someone would need to create a DG (or DL) on the fly is that
they may need to
use variables to change things like the headers. The inability to use
code-behind variables inside server controls - the
single greatest handicap of ASP.NET - can be overcome by building your
literals from variables via
dynamic DG creation.
For example, say you wanted to do the following:

<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"../index.aspx?catID=" & currentCat & "|" &
DataBinder.Eval(Container.DataItem, "CategoryID")%>' Text='<%#
DataBinder.Eval(Container.DataItem, "CategoryName") %>'></asp:HyperLink>

where currentCat was some variable declared in a code behind.
It is impossible to do because you cannot use variables from a code-behind
in a server control (i.e. 'currentCat' would never contain a value no matter
where it was declared). The only workaround is to dynamically create your
control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top