473,698 Members | 2,888 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 16056
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
2334
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
3117
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
6546
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
3363
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
1000
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
1057
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
1797
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
2181
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
4755
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
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
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
7741
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...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
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...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.