Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Creating a DetailsView programatically

Reply
Thread Tools

Creating a DetailsView programatically

 
 
Fernando A. Gómez F.
Guest
Posts: n/a
 
      11-21-2008
Hello all.

I'm building a WebControl. In it's CreateChildControls, I'm creating a
DataSource and a DetailsView controls and set de DV's DataSourceID to
the control I just created.

Now, I'm not sure how to add the template fields and then bind them. I
mean, I'm lookin the translation from this:

<aspetailsView ID="CatalogDetailView" runat="server" ...etc... >
<Fields>
<asp:TemplateField HeaderText="Aplicación *"
HeaderStyle-HorizontalAlign="Left"
ItemStyle-HorizontalAlign="left" >
<InsertItemTemplate>
<aspropDownList ID="ddlAplicacion" runat="server"
Width="205px" DataSourceID="AplicacionCatDataSource"
DataValueField="ClaveAplicacion"
DataTextField="NombreAplicacion"
SelectedValue='<%# Bind("IdAplicacion") %>' <------here
AutoPostBack="true" />
</InsertItemTemplate>
<EditItemTemplate >
...etc...
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</aspetailsView>

Into C# code. I mean, in the ASP.NET page I just use the <%# Bind(...)
%> tag and be done with it. How do I translate that into C# code? How
can I bind the control?

Any help will be appreciated. Thanks in advance

Regards,
Fernando.
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      11-21-2008
binding expression are converted code when the aspx is compiled. when
you create dropdown, after the databind, just set the selectedValue.

-- bruce (sqlwork.com)

Fernando A. Gómez F. wrote:
> Hello all.
>
> I'm building a WebControl. In it's CreateChildControls, I'm creating a
> DataSource and a DetailsView controls and set de DV's DataSourceID to
> the control I just created.
>
> Now, I'm not sure how to add the template fields and then bind them. I
> mean, I'm lookin the translation from this:
>
> <aspetailsView ID="CatalogDetailView" runat="server" ...etc... >
> <Fields>
> <asp:TemplateField HeaderText="Aplicación *"
> HeaderStyle-HorizontalAlign="Left"
> ItemStyle-HorizontalAlign="left" >
> <InsertItemTemplate>
> <aspropDownList ID="ddlAplicacion" runat="server"
> Width="205px" DataSourceID="AplicacionCatDataSource"
> DataValueField="ClaveAplicacion"
> DataTextField="NombreAplicacion"
> SelectedValue='<%# Bind("IdAplicacion") %>' <------here
> AutoPostBack="true" />
> </InsertItemTemplate>
> <EditItemTemplate >
> ...etc...
> </EditItemTemplate>
> </asp:TemplateField>
> </Fields>
> </aspetailsView>
>
> Into C# code. I mean, in the ASP.NET page I just use the <%# Bind(...)
> %> tag and be done with it. How do I translate that into C# code? How
> can I bind the control?
>
> Any help will be appreciated. Thanks in advance
>
> Regards,
> Fernando.

 
Reply With Quote
 
 
 
 
Fernando A. Gómez F.
Guest
Posts: n/a
 
      11-21-2008
bruce barker wrote:
> binding expression are converted code when the aspx is compiled. when
> you create dropdown, after the databind, just set the selectedValue.
>
> -- bruce (sqlwork.com)


Hello Bruce,

thanks for the answer. Do you mean that I'd have to subscribe to the
DataSource's DataBind event and manually set the SelectedValue?

Thanks.
 
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
Creating a custom user control programatically Big Daddy ASP .Net Building Controls 2 11-02-2006 10:43 PM
DetailsView Does NOT Fire ModeChanged if populated programatically =?Utf-8?B?bWlrZQ==?= ASP .Net 0 07-20-2006 04:02 PM
DetailsView - Changing to Insert Mode (Not By Using the Insert Button In the DetailsView Control) Feege ASP .Net Web Controls 0 12-20-2005 12:28 AM
Creating onClick event for dynamically (programatically) created buttons Hrvoje Vrbanc ASP .Net 1 07-10-2003 04:55 PM
Creating Datagrid Programatically Raja Rajan J ASP .Net Datagrid Control 0 07-08-2003 02:08 PM



Advertisments