468,505 Members | 1,657 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

FindControl in a Datalist

Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate 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
EditItemTemplate.

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 7175
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********@ldmkusa.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate 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
EditItemTemplate.

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 EditItemTemplate, 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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate 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
EditItemTemplate.

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 EditItemTemplate, 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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate 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
EditItemTemplate.

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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If you're looking for a dropdownlist that's in the EditItemTemplate, 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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
Problem:
I am trying to use FindControl to grab a dropdownlist that is in the
EditItemTemplate 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
EditItemTemplate.

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********@ldmkusa.com> wrote in message
news:e8**************@TK2MSFTNGP09.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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If you're looking for a dropdownlist that's in the EditItemTemplate,

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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
news:#h**************@TK2MSFTNGP10.phx.gbl...
> Problem:
> I am trying to use FindControl to grab a dropdownlist that is in the
> EditItemTemplate 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
> EditItemTemplate.
>
> 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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP11.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********@ldmkusa.com> wrote in message
news:e8**************@TK2MSFTNGP09.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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If you're looking for a dropdownlist that's in the EditItemTemplate,

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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
> news:#h**************@TK2MSFTNGP10.phx.gbl...
> > Problem:
> > I am trying to use FindControl to grab a dropdownlist that is in
the > > EditItemTemplate 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
> > EditItemTemplate.
> >
> > 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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP11.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********@ldmkusa.com> wrote in message
news:e8**************@TK2MSFTNGP09.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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
If you're looking for a dropdownlist that's in the EditItemTemplate,

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**@componentone.com> wrote in message
news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
> news:#h**************@TK2MSFTNGP10.phx.gbl...
> > Problem:
> > I am trying to use FindControl to grab a dropdownlist that is in
the > > EditItemTemplate 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
> > EditItemTemplate.
> >
> > 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********@ldmkusa.com> wrote in message
news:ey**************@TK2MSFTNGP12.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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP11.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********@ldmkusa.com> wrote in message
news:e8**************@TK2MSFTNGP09.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*********@mindspring.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> If you're looking for a dropdownlist that's in the EditItemTemplate,
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**@componentone.com> wrote in message
> news:uc**************@TK2MSFTNGP09.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********@ldmkusa.com> wrote in message
> > news:#h**************@TK2MSFTNGP10.phx.gbl...
> > > Problem:
> > > I am trying to use FindControl to grab a dropdownlist that is in the > > > EditItemTemplate 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
> > > EditItemTemplate.
> > >
> > > 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rimu Atkinson | last post: by
4 posts views Thread by MattB | last post: by
2 posts views Thread by Greg Fischer | last post: by
1 post views Thread by Paul | last post: by
2 posts views Thread by christof | last post: by
2 posts views Thread by Srini | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.