473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating a DetailsView programatically

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:

<asp:DetailsView ID="CatalogDetailView" runat="server" ...etc... >
<Fields>
<asp:TemplateField HeaderText="Aplicación *"
HeaderStyle-HorizontalAlign="Left"
ItemStyle-HorizontalAlign="left" >
<InsertItemTemplate>
<asp:DropDownList 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>
</asp:DetailsView>

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.
Nov 21 '08 #1
2 2811
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:

<asp:DetailsView ID="CatalogDetailView" runat="server" ...etc... >
<Fields>
<asp:TemplateField HeaderText="Aplicación *"
HeaderStyle-HorizontalAlign="Left"
ItemStyle-HorizontalAlign="left" >
<InsertItemTemplate>
<asp:DropDownList 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>
</asp:DetailsView>

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.
Nov 21 '08 #2
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.
Nov 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sck10 | last post by:
Hello, I have a GridView that list all the employees in our group. My select button (link) when clicked will open a DetailsView control of the employee selected. I have one BoundField in the...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
2
by: K B | last post by:
Hi, Is there ANY WAY to hide a row/field in a DetailsView based on meeting a condition at the ItemCreated or ModeChanging event -- or any other way? There appears not to be, but I was hoping for...
1
by: cisco | last post by:
I've been trying to figure out how the client of a DetailsView or FormView should handle the ItemUpdating event when setting the datasource programatically. I want to do something simple like...
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
2
by: nolan | last post by:
I have an asp.net 2.0 page with a gridview and detailsview on the same page set up in a master-details scenario. The gridview and detailsview have separate SQL data sources. The user enters...
0
by: drasko | last post by:
I have DetailsView control in Insert mode and I want to fill its cells initially with values retrieved from ActiveDirectory. User would add some data in other cells of DetailsView and after...
0
by: kamlesh | last post by:
Hi Experts, I have a question on the ASP.NET 2.0 Details view control I dont like using the SQLDataSource to bind the data to the DetailsView control.. I dont like the idea of placing Queries...
0
by: jemitch0 | last post by:
I have a 2 column table that contains FK to other tables in my app. The 2 columns together form the PK for the table. I want to be able to update these values using a Detailsview, but can't get the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.