473,847 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to access control in edititemtemplat e of detailsview? (ASP 2.0

Hello, I hope somebody can help me with this!
I have 2 listboxes in the edititemtemplat e of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmaticall y (not through databinding). If I use
detailsview.fin dcontrol(contro lname) then an empty object is returned. How
can I address these controls?
Thank you for your time.
Nov 23 '05 #1
4 16075
Hi Frits,

In the dropdownlist within the DetailsView's TemplateField add OnDatabinding
= "DropDownList1_ DataBinding" and in the CodeBehind add
protected void DropDownList1_D ataBinding(obje ct sender, EventsArgs e)
{
// do something
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:
Hello, I hope somebody can help me with this!
I have 2 listboxes in the edititemtemplat e of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmaticall y (not through databinding). If I use
detailsview.fin dcontrol(contro lname) then an empty object is returned. How
can I address these controls?
Thank you for your time.

Nov 23 '05 #2
That's brilliant! Thanks for asnwering so quickly.

"Phillip Williams" wrote:
Hi Frits,

In the dropdownlist within the DetailsView's TemplateField add OnDatabinding
= "DropDownList1_ DataBinding" and in the CodeBehind add
protected void DropDownList1_D ataBinding(obje ct sender, EventsArgs e)
{
// do something
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:
Hello, I hope somebody can help me with this!
I have 2 listboxes in the edititemtemplat e of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmaticall y (not through databinding). If I use
detailsview.fin dcontrol(contro lname) then an empty object is returned. How
can I address these controls?
Thank you for your time.

Nov 23 '05 #3
You are welcome Frits.

I might also add that the reason you could not find the control upon
databinding is that it was not created yet. If you wanted to do it the way
you tried then you should use the DetailsVeiw.Dat aBound event instead, e.g,
DetailsView.Dat aBound += new EventHandler(De tailsView1_Data Bound);

and then

void DetailsView1_Da taBound(object sender, EventArgs e)
{
if(((DetailsVie w)sender).Curre ntMode== DetailsViewMode .Edit)
{
DropDownList
ddl=(DropDownLi st)((DetailsVie w)sender).FindC ontrol("DropDow nList1");
if (ddl1 !=null) //you found the dropdownlist
{
//execute statements to add the desired data to it
}
}

}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:
That's brilliant! Thanks for asnwering so quickly.

"Phillip Williams" wrote:
Hi Frits,

In the dropdownlist within the DetailsView's TemplateField add OnDatabinding
= "DropDownList1_ DataBinding" and in the CodeBehind add
protected void DropDownList1_D ataBinding(obje ct sender, EventsArgs e)
{
// do something
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:
Hello, I hope somebody can help me with this!
I have 2 listboxes in the edititemtemplat e of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmaticall y (not through databinding). If I use
detailsview.fin dcontrol(contro lname) then an empty object is returned. How
can I address these controls?
Thank you for your time.

Nov 23 '05 #4
Thank you, Phillip!
I tried the databound event earlier, but unfortunately it seems that
controls in the edititemtemplat e are not created at that time. Only when the
detailsview is actually in edit mode.
Cheers,
Frits

"Phillip Williams" wrote:
You are welcome Frits.

I might also add that the reason you could not find the control upon
databinding is that it was not created yet. If you wanted to do it the way
you tried then you should use the DetailsVeiw.Dat aBound event instead, e.g,
DetailsView.Dat aBound += new EventHandler(De tailsView1_Data Bound);

and then

void DetailsView1_Da taBound(object sender, EventArgs e)
{
if(((DetailsVie w)sender).Curre ntMode== DetailsViewMode .Edit)
{
DropDownList
ddl=(DropDownLi st)((DetailsVie w)sender).FindC ontrol("DropDow nList1");
if (ddl1 !=null) //you found the dropdownlist
{
//execute statements to add the desired data to it
}
}

}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:
That's brilliant! Thanks for asnwering so quickly.

"Phillip Williams" wrote:
Hi Frits,

In the dropdownlist within the DetailsView's TemplateField add OnDatabinding
= "DropDownList1_ DataBinding" and in the CodeBehind add
protected void DropDownList1_D ataBinding(obje ct sender, EventsArgs e)
{
// do something
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Frits van Soldt" wrote:

> Hello, I hope somebody can help me with this!
> I have 2 listboxes in the edititemtemplat e of a detailsview. In the
> databound event of the detailsview I would like to fill the listboxes
> programmaticall y (not through databinding). If I use
> detailsview.fin dcontrol(contro lname) then an empty object is returned. How
> can I address these controls?
> Thank you for your time.

Nov 23 '05 #5

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

Similar topics

8
2342
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3" ItemStyle-HorizontalAlign="center" ItemStyle-VerticalAlign="top"> <ItemTemplate><%# CType(Container.DataItem("DateStatut"),DateTime).ToString("yyyy-MM-dd") %></ItemTemplate> <EditItemTemplate> <asp:TextBox width="80" CssClass="edit_item" id="txtDateStatut"
1
3137
by: pjbates | last post by:
Hi, I've been using the GridView and DetailsView controls for a while, and I'm beginning to get annoyed by the redundancy of EditItemTemplate and InsertItemTemplate in many cases. In the following code, both edit and insert templates are identical. It would be great if I could define a generic template to be used for both edits and inserts. I know that there are many situations where the edit and insert templates will differ, but for...
2
6555
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
1
3372
by: womblesjc | last post by:
I have a data bound Details View control in asp.net 2.0 that formats a phone number. The 'Default Mode' for the control is set to Edit. The phone number field is a template field and I can successfully call a function that formats the phone number when the control is filled. But when updating, the value being passed in to my format function is vbNull instead of the value in the phone number field of the control. How can I get the update...
0
1008
by: K B | last post by:
I need to validate fields in a DetailsView when the user clicks Update. In Insert, I use: <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="InitiateJobEdit" ControlToValidate="DropDownList1" InitialValue="0" Text="(select one)" Runat="Server" /> in the EditItemTemplate source. Nothing fires.
0
1061
by: Jim McGivney | last post by:
IN VWD, on an aspx page I have a DetailsView control. I have placed an AccessDataSource (AccessDataSource3) in the EditItemTemplate for the Row called "Sex". I want to programatically change the datafile for the AccessDataSource. In the Page_Load event I try: AccessDataSource3.DataFile =
0
1804
by: yukijocelyn | last post by:
I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSource control, and using Gridview to pull the data from the database. I am able to see the contents in the database, but whenever I click "Delete" or "Update", the data never gets deleted or get updated repectively. It feels as if it was a normal page load, nothing is done to the data in the database. I also have another problem...
1
2186
by: ajrock2000 | last post by:
I am using a DetailsView to display some data. I am basically getting a firstname, and lastname fields from a database (the database cannot be changed, nor the queries), and I must concatenate the , . I want to incorporate this into a detailsview like so... <asp:TemplateField HeaderText="Name:"> <ItemTemplate> <%#Eval("firstname")%>, <%#Eval("lastname")%> </ItemTemplate> </asp:TemplateField> ...
18
4769
by: Dan | last post by:
Hi, There is a detailsview which contains a textbox in editmode. How to get the id of the textbox in javascript? I tried this: <asp:DetailsView ID="DetailsView1" runat="server" > <asp:TemplateField> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </EditItemTemplate>
0
10983
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10706
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10338
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9482
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4119
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.