473,748 Members | 5,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FindControl in a Datalist

Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplat e of a Datalist and then Bind it to a dataset. I also then
need to put the correct values in all of the text boxes in the
EditItemTemplat e.

I have set the EditItemIndex for the Datalist to -1, and then bound the
Datalist. I then want to Bind the DropDown, and populate the values.

All attempts to use FindControl on the control return "Nothing"

Any assistance is appreciated.

Nov 18 '05 #1
8 7435
Adam,

I am pretty sure you need to use the onITemCreated event after you have
bound your datalist. In this event you can bind you dropdownlist as you go
each item gets created. Does that sound right?

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplat e of a Datalist and then Bind it to a dataset. I also then
need to put the correct values in all of the text boxes in the
EditItemTemplat e.

I have set the EditItemIndex for the Datalist to -1, and then bound the
Datalist. I then want to Bind the DropDown, and populate the values.

All attempts to use FindControl on the control return "Nothing"

Any assistance is appreciated.

Nov 18 '05 #2
If you're looking for a dropdownlist that's in the EditItemTemplat e, you'll
need a to do so when the value for EditItemIndex is other than -1! Then, you
can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist,
and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Adam,

I am pretty sure you need to use the onITemCreated event after you have
bound your datalist. In this event you can bind you dropdownlist as you go each item gets created. Does that sound right?

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplat e of a Datalist and then Bind it to a dataset. I also then need to put the correct values in all of the text boxes in the
EditItemTemplat e.

I have set the EditItemIndex for the Datalist to -1, and then bound the
Datalist. I then want to Bind the DropDown, and populate the values.

All attempts to use FindControl on the control return "Nothing"

Any assistance is appreciated.


Nov 18 '05 #3
If you're looking for a dropdownlist that's in the EditItemTemplat e, you'll
need a to do so when the value for EditItemIndex is other than -1! Then, you
can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist,
and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Adam,

I am pretty sure you need to use the onITemCreated event after you have
bound your datalist. In this event you can bind you dropdownlist as you go each item gets created. Does that sound right?

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplat e of a Datalist and then Bind it to a dataset. I also then need to put the correct values in all of the text boxes in the
EditItemTemplat e.

I have set the EditItemIndex for the Datalist to -1, and then bound the
Datalist. I then want to Bind the DropDown, and populate the values.

All attempts to use FindControl on the control return "Nothing"

Any assistance is appreciated.


Nov 18 '05 #4
Ok, just to be clear, I want to bind a datalist and populate controls when
the datalist is in edit mode. I want to display a couple dropdown and some
textboxes that would have been straight labels in the non-edit view.

It is now time to update the data, so the new controls are needed.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
If you're looking for a dropdownlist that's in the EditItemTemplat e, you'll need a to do so when the value for EditItemIndex is other than -1! Then, you can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist,
and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Adam,

I am pretty sure you need to use the onITemCreated event after you have
bound your datalist. In this event you can bind you dropdownlist as you
go
each item gets created. Does that sound right?

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplat e of a Datalist and then Bind it to a dataset. I also

then need to put the correct values in all of the text boxes in the
EditItemTemplat e.

I have set the EditItemIndex for the Datalist to -1, and then bound the Datalist. I then want to Bind the DropDown, and populate the values.

All attempts to use FindControl on the control return "Nothing"

Any assistance is appreciated.



Nov 18 '05 #5
Yes. Make your column(s) templated, and add the dropdowns and textboxes to
the edit item template. Set the databindings of these controls as you like.
If you want the dropdowns to display the value from the label, you'll
probably need some code in the itemdatabound event. Use select case for the
edit item type to operate only on this item, then use .Findcontrol to find
it by ID, and set the selectedindex to the item which matches the value from
your data source at the .datasetindex of the item.

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl...
Ok, just to be clear, I want to bind a datalist and populate controls when
the datalist is in edit mode. I want to display a couple dropdown and some textboxes that would have been straight labels in the non-edit view.

It is now time to update the data, so the new controls are needed.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
If you're looking for a dropdownlist that's in the EditItemTemplat e,

you'll
need a to do so when the value for EditItemIndex is other than -1! Then,

you
can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist,
and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
Adam,

I am pretty sure you need to use the onITemCreated event after you have bound your datalist. In this event you can bind you dropdownlist as you
go
each item gets created. Does that sound right?

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:#h******** ******@TK2MSFTN GP10.phx.gbl...
> Problem:
> I am trying to use FindControl to grab a dropdownlist that is in the
> EditItemTemplat e of a Datalist and then Bind it to a dataset. I also then
> need to put the correct values in all of the text boxes in the
> EditItemTemplat e.
>
> I have set the EditItemIndex for the Datalist to -1, and then bound

the > Datalist. I then want to Bind the DropDown, and populate the

values. >
> All attempts to use FindControl on the control return "Nothing"
>
> Any assistance is appreciated.
>
>
>



Nov 18 '05 #6
Ok.
I have all of that figured out now, and I thank you for your help. I have
pretty much the same problem now however when I want to pass the
changed/updated fields back to the database.

In my head, I want to click the save button. Then in ItemCommand (if save
was clicked) stick each of the new values into a sqlcommand with parameters
and pass them off to the stored procedure.

The problem once again is grabbing the controls and extracting their values.
I would like to use FindControl, but this still is returning nothing in the
ItemCommand event.

Help?
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Yes. Make your column(s) templated, and add the dropdowns and textboxes to
the edit item template. Set the databindings of these controls as you like. If you want the dropdowns to display the value from the label, you'll
probably need some code in the itemdatabound event. Use select case for the edit item type to operate only on this item, then use .Findcontrol to find
it by ID, and set the selectedindex to the item which matches the value from your data source at the .datasetindex of the item.

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl...
Ok, just to be clear, I want to bind a datalist and populate controls when
the datalist is in edit mode. I want to display a couple dropdown and

some
textboxes that would have been straight labels in the non-edit view.

It is now time to update the data, so the new controls are needed.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
If you're looking for a dropdownlist that's in the EditItemTemplat e,

you'll
need a to do so when the value for EditItemIndex is other than -1! Then,
you
can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist, and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
> Adam,
>
> I am pretty sure you need to use the onITemCreated event after you have > bound your datalist. In this event you can bind you dropdownlist
as you
go
> each item gets created. Does that sound right?
>
> "Adam Billmeier" <ab********@ldm kusa.com> wrote in message
> news:#h******** ******@TK2MSFTN GP10.phx.gbl...
> > Problem:
> > I am trying to use FindControl to grab a dropdownlist that is in
the > > EditItemTemplat e of a Datalist and then Bind it to a dataset. I

also then
> > need to put the correct values in all of the text boxes in the
> > EditItemTemplat e.
> >
> > I have set the EditItemIndex for the Datalist to -1, and then
bound the
> > Datalist. I then want to Bind the DropDown, and populate the

values. > >
> > All attempts to use FindControl on the control return "Nothing"
> >
> > Any assistance is appreciated.
> >
> >
> >
>
>



Nov 18 '05 #7
Got it working.
Thanks

"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Yes. Make your column(s) templated, and add the dropdowns and textboxes to
the edit item template. Set the databindings of these controls as you like. If you want the dropdowns to display the value from the label, you'll
probably need some code in the itemdatabound event. Use select case for the edit item type to operate only on this item, then use .Findcontrol to find
it by ID, and set the selectedindex to the item which matches the value from your data source at the .datasetindex of the item.

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl...
Ok, just to be clear, I want to bind a datalist and populate controls when
the datalist is in edit mode. I want to display a couple dropdown and

some
textboxes that would have been straight labels in the non-edit view.

It is now time to update the data, so the new controls are needed.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
If you're looking for a dropdownlist that's in the EditItemTemplat e,

you'll
need a to do so when the value for EditItemIndex is other than -1! Then,
you
can look for the case of e.item is edit item type in the itemdatabound
event, and use .findcontrol on the item itself to find your dropdownlist, and bind it.

"Tom Bray" <to**@component one.com> wrote in message
news:uc******** ******@TK2MSFTN GP09.phx.gbl...
> Adam,
>
> I am pretty sure you need to use the onITemCreated event after you have > bound your datalist. In this event you can bind you dropdownlist
as you
go
> each item gets created. Does that sound right?
>
> "Adam Billmeier" <ab********@ldm kusa.com> wrote in message
> news:#h******** ******@TK2MSFTN GP10.phx.gbl...
> > Problem:
> > I am trying to use FindControl to grab a dropdownlist that is in
the > > EditItemTemplat e of a Datalist and then Bind it to a dataset. I

also then
> > need to put the correct values in all of the text boxes in the
> > EditItemTemplat e.
> >
> > I have set the EditItemIndex for the Datalist to -1, and then
bound the
> > Datalist. I then want to Bind the DropDown, and populate the

values. > >
> > All attempts to use FindControl on the control return "Nothing"
> >
> > Any assistance is appreciated.
> >
> >
> >
>
>



Nov 18 '05 #8
Are you checking for the edititem?
"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:ey******** ******@TK2MSFTN GP12.phx.gbl...
Ok.
I have all of that figured out now, and I thank you for your help. I have
pretty much the same problem now however when I want to pass the
changed/updated fields back to the database.

In my head, I want to click the save button. Then in ItemCommand (if save
was clicked) stick each of the new values into a sqlcommand with parameters and pass them off to the stored procedure.

The problem once again is grabbing the controls and extracting their values. I would like to use FindControl, but this still is returning nothing in the ItemCommand event.

Help?
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Yes. Make your column(s) templated, and add the dropdowns and textboxes to
the edit item template. Set the databindings of these controls as you

like.
If you want the dropdowns to display the value from the label, you'll
probably need some code in the itemdatabound event. Use select case for

the
edit item type to operate only on this item, then use .Findcontrol to find it by ID, and set the selectedindex to the item which matches the value

from
your data source at the .datasetindex of the item.

"Adam Billmeier" <ab********@ldm kusa.com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl...
Ok, just to be clear, I want to bind a datalist and populate controls

when the datalist is in edit mode. I want to display a couple dropdown and

some
textboxes that would have been straight labels in the non-edit view.

It is now time to update the data, so the new controls are needed.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> If you're looking for a dropdownlist that's in the EditItemTemplat e,
you'll
> need a to do so when the value for EditItemIndex is other than -1! Then, you
> can look for the case of e.item is edit item type in the itemdatabound > event, and use .findcontrol on the item itself to find your

dropdownlist,
> and bind it.
>
> "Tom Bray" <to**@component one.com> wrote in message
> news:uc******** ******@TK2MSFTN GP09.phx.gbl...
> > Adam,
> >
> > I am pretty sure you need to use the onITemCreated event after you

have
> > bound your datalist. In this event you can bind you dropdownlist as you
> go
> > each item gets created. Does that sound right?
> >
> > "Adam Billmeier" <ab********@ldm kusa.com> wrote in message
> > news:#h******** ******@TK2MSFTN GP10.phx.gbl...
> > > Problem:
> > > I am trying to use FindControl to grab a dropdownlist that is in the > > > EditItemTemplat e of a Datalist and then Bind it to a dataset. I

also
> then
> > > need to put the correct values in all of the text boxes in the
> > > EditItemTemplat e.
> > >
> > > I have set the EditItemIndex for the Datalist to -1, and then bound the
> > > Datalist. I then want to Bind the DropDown, and populate the

values.
> > >
> > > All attempts to use FindControl on the control return "Nothing"
> > >
> > > Any assistance is appreciated.
> > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #9

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

Similar topics

1
425
by: Rimu Atkinson | last post by:
hi all i use FindControl to get a textbox, and i get a textbox object, but it's ..Text property is empty. some background info: i have a DataList, which has a template column in it, and in that template column i define a textbox. <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate>
2
1543
by: Rimu Atkinson | last post by:
hi all i use FindControl to get a textbox, and i get a textbox object, but it's ..Text property is empty. some background info: i have a DataList, which has a template column in it, and in that template column i define a textbox. <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate>
4
4154
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so at compile time I don't know what text boxes are going to be present at run time. This is where it seems the FindControl method would be come into play. I loop through a list of control (all textboxes) names I created on page load and see if they...
2
2168
by: Greg Fischer | last post by:
I need to access the properties of a control that is nested in 2 datalists. How do you use findcontrol method to do that? what I have is like this: <asp:datalist id="dlist" runat="server"> <edititemtemplate> <asp:datalist id="dlistdet" runat="server"> <asp:dropdownlist id="ddlTypes" runat="server"></dropdownlist> </asp:datalist>
3
19342
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS 2005 (ASP 2.0) and VB .NET. I have a page with a datalist, a gridview and then other data controls, nested in that order. This all works great, and produces a nice looking page, but I cannot for the life of me figure out how to reference
1
8527
by: Paul | last post by:
I have an item in the aspx part of my page: <a id="PreviousPageNav" runat="server" > <asp:Image runat=server ID="PreviousImage" ImageUrl="~/Images/Nav/previous.gif" /> </a> that I put in the header of a DataList.
2
6565
by: christof | last post by:
How to do it: My page: <asp:DataList ID="dataListRoleMembers" ...> .... <FooterTemplate> <asp:LinkButton ID="btnAddMember" runat="server" OnClick="btnAddMember_Click">Add...</asp:LinkButton> <asp:TextBox ID="txtAddMember" runat="server"></asp:TextBox>
2
2073
by: jobs | last post by:
I have two Nested repeating Datalists with different data sources. Currently the second Datalist is set to visible=false I have an oncommand button on the first, that when selected I would like to make it's sub datalist visible. I'm a bit confused about how to refrence the instance of the second datalist.
2
5923
by: Srini | last post by:
I customized the SideBarTemplate of the Wizard control and added a Label with ID Label1 to it. I want to change the Text of the label based on the current step. But the following always returns null Label L = (Label)Wizard1.FindControl( "Label1" ); As per the help file, this should return the Label. Here is the script for the template <SideBarTemplate>
0
8987
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
8826
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,...
1
9316
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
9241
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...
1
6793
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
6073
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
4597
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
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
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

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.