Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

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

 
Thread Tools Search this Thread
Old 11-22-2005, 03:40 PM   #1
Default 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.


=?Utf-8?B?RnJpdHMgdmFuIFNvbGR0?=
  Reply With Quote
Old 11-22-2005, 04:08 PM   #2
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
 
Posts: n/a
Default RE: How to access control in edititemtemplate of detailsview? (ASP 2.0
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.



=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
  Reply With Quote
Old 11-22-2005, 05:28 PM   #3
=?Utf-8?B?RnJpdHMgdmFuIFNvbGR0?=
 
Posts: n/a
Default RE: How to access control in edititemtemplate of detailsview? (ASP
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.



=?Utf-8?B?RnJpdHMgdmFuIFNvbGR0?=
  Reply With Quote
Old 11-22-2005, 05:46 PM   #4
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
 
Posts: n/a
Default RE: How to access control in edititemtemplate of detailsview? (ASP
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.



=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
  Reply With Quote
Old 11-23-2005, 07:02 AM   #5
=?Utf-8?B?RnJpdHMgdmFuIFNvbGR0?=
 
Posts: n/a
Default RE: How to access control in edititemtemplate of detailsview? (ASP
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.



=?Utf-8?B?RnJpdHMgdmFuIFNvbGR0?=
  Reply With Quote
Old 07-19-2006, 08:50 PM   #6
ashishbuddha
Junior Member
 
Join Date: Jul 2006
Posts: 2
Post bindind data in drop dropdownlist in edit mode
hello frits and philip,


i am having the same problem. i need to user to pick from drop down list when in edit mode. I am not able to bind it. When i write the codebehind detailsview_databinding, i am getting an error saying the dropperson (which is dropdowmlist id in edit itemtemplate) is not declared. Can u please help me how do i get around this issue.

Thx
ashish


ashishbuddha
ashishbuddha is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Authicating Web control using MS Access instead of SQL Teiko21 Software 0 05-16-2008 07:13 PM
I cant access the MCP site T3M4N MCTS 1 03-18-2008 06:21 PM
Mind Control and CIA'S BOURNE IDENTITY PLOT soleilmavis@gmail.com DVD Video 2 08-03-2007 09:54 PM
Ajax Atlas not working in User Control faiq Software 0 09-16-2006 08:28 AM
FS: JP1 cable to program your universial remote control, now youcan control anything you want! Mike DVD Video 0 07-15-2005 02:46 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46