473,403 Members | 2,366 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,403 software developers and data experts.

How to access control in edititemtemplate of detailsview? (ASP 2.0

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

In the dropdownlist within the DetailsView's TemplateField add OnDatabinding
= "DropDownList1_DataBinding" and in the CodeBehind add
protected void DropDownList1_DataBinding(object 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 edititemtemplate of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmatically (not through databinding). If I use
detailsview.findcontrol(controlname) 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_DataBinding(object 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 edititemtemplate of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmatically (not through databinding). If I use
detailsview.findcontrol(controlname) 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.DataBound event instead, e.g,
DetailsView.DataBound += new EventHandler(DetailsView1_DataBound);

and then

void DetailsView1_DataBound(object sender, EventArgs e)
{
if(((DetailsView)sender).CurrentMode== DetailsViewMode.Edit)
{
DropDownList
ddl=(DropDownList)((DetailsView)sender).FindContro l("DropDownList1");
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_DataBinding(object 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 edititemtemplate of a detailsview. In the
databound event of the detailsview I would like to fill the listboxes
programmatically (not through databinding). If I use
detailsview.findcontrol(controlname) 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 edititemtemplate 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.DataBound event instead, e.g,
DetailsView.DataBound += new EventHandler(DetailsView1_DataBound);

and then

void DetailsView1_DataBound(object sender, EventArgs e)
{
if(((DetailsView)sender).CurrentMode== DetailsViewMode.Edit)
{
DropDownList
ddl=(DropDownList)((DetailsView)sender).FindContro l("DropDownList1");
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_DataBinding(object 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 edititemtemplate of a detailsview. In the
> databound event of the detailsview I would like to fill the listboxes
> programmatically (not through databinding). If I use
> detailsview.findcontrol(controlname) 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
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"...
1
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...
2
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...
1
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...
0
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"...
0
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...
0
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...
1
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 ,...
18
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" >...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.