Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamic Web Controls

Reply
Thread Tools

Dynamic Web Controls

 
 
Jay Esguerra
Guest
Posts: n/a
 
      09-04-2003
Is it possible to do this:

<%
Dim i as integer

For i = 65 to 90

%>

<asp:Linkbutton Text=chr(i) runat=server />

<%
Next
%>

*** I am trying to create a link button dynamically. Or
is there another way...Keep in mind I am a newbie to .net
and am accustomed to ASP.
 
Reply With Quote
 
 
 
 
Ezra Epstein
Guest
Posts: n/a
 
      09-13-2003
The recommended approach is to use an ASP:Repeater control and then put the
asp:LinkButton(s) (or whatever else) inside.

For example:

<snip>
<asp:repeater id="ItemRepeater" Runat="server" DataSource="<%#
CategoryContents %>">
<ItemTemplate>
<p class="CategoryItem">
<asp:LinkButton ID="lnkShowUser" Runat="server" CausesValidation="false"
CommandArgument='<%# DataBinder.Eval(Container.DataItem,
"ReferencedItem.PkGuid") %>'>
<%# DataBinder.Eval(Container.DataItem, "ReferencedItem.FullName") %>
</asp:LinkButton>
<br>
<%# DataBinder.Eval(Container.DataItem, "ReferencedItem.PhoneNumber") %>
</p>
</ItemTemplate>
<%-- SeparatorTemplate>
<br>
</SeparatorTemplate --%>
</asp:repeater>
</snip>

The code-behind has a public CategoryContents property that returns an
ICollection (something that can be enumerated). Then I use DataBinder.Eval
to set a commandArgument (so that I can distinguish which ListButton was
clicked). Finally you implement the call-back method for the repeater (not
for the link button) and then distinguish the items based on the
commandArgument.

Hope that helps,

Ezra E.

"Jay Esguerra" <(E-Mail Removed)> wrote in message
news:214b01c3731e$bb9eb760$(E-Mail Removed)...
> Is it possible to do this:
>
> <%
> Dim i as integer
>
> For i = 65 to 90
>
> %>
>
> <asp:Linkbutton Text=chr(i) runat=server />
>
> <%
> Next
> %>
>
> *** I am trying to create a link button dynamically. Or
> is there another way...Keep in mind I am a newbie to .net
> and am accustomed to ASP.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net 5 01-10-2007 10:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Web Controls 4 12-21-2006 02:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Building Controls 4 12-21-2006 02:50 AM
Dynamic Controls created by Dynamic Controls Ronald ASP .Net 2 01-17-2006 12:44 AM
Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls Denny Smolinski via .NET 247 ASP .Net Web Controls 1 05-04-2004 09:15 PM



Advertisments