Inside the event handler the runtime gives a RepeaterCommand EventArgs
parameter (e). The e.Item property represents the Repeater Item where
the event occured (the footer item). When the code says
e.Item.FindCont rol(<controlnam e>), it is saying "Go to the
RepeaterItem where the event occured (the footer) and look for the
control with this name. Since the footer doesn't have that control the
call returns Nothing. Make any more sense?
I have a couple relavent articles here:
In Search of ASP.NET Controls
http://odetocode.com/Articles/116.aspx
DropDownList Controls In an ASP.Net DataGrid
(using a DataGrid, but the concepts are the same)
http://odetocode.com/Articles/231.aspx
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 8 Nov 2004 06:13:02 -0800, "huzz"
<hu**@discussio ns.microsoft.co m> wrote:
Scott, Thank you so much.
I moved to button inside the ItemTemplate and its working now.. :)
Can you please explain whats the reason i couldn't find the control when i
had the button inside the FooterTemplate?
Is there any tutorials which explains repeater in great details?
many thanks again
"Scott Allen" wrote:
In this case, the button is in the footer template, so I'm guessing
e.Item refers to the footer template instead of the item where the
drop down list lives. If you do not know which item the user was just
editing you might have to loop through all the items in the repeater
and get the updated DropDownList values.
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 8 Nov 2004 03:04:01 -0800, "huzz"
<hu**@discussio ns.microsoft.co m> wrote:
>I am trying to access a DropDownList control inside a repeater using
>ItemCommand as shown below but for some reason i can't access the
>DropDownList . When i step through the debug i get <undefine value> for the
>DropDownList
>
>What am i doing wrong?
>
><asp:Repeate r ID="Repeater1" Runat="server" OnItemDataBound ="create_ddl "
>OnItemCommand= "Repeater1_Item Command">
> <HeaderTemplate >
> <table>
> <tr>
> Edit Details
> </tr>
> </HeaderTemplate>
> <ItemTemplate >
> <tr>
> <td>
> <asp:DropDownLi st ID="ddl" Runat="server"> </asp:DropDownLis t>
> </td>
> </tr>
>
> <tr>
> <td>
> <asp:TextBox ID="StaffCommen ts" Runat="server"
>TextMode="Mult iLine" Text='<%# DataBinder.Eval (Container.Data Item,
>"StaffPriority ")%>' Width="400" Height="40"></asp:TextBox>
> </td>
> </tr>
>
></ItemTemplate>
><FooterTemplat e>
><tr>
><td colspan="2"><as p:Button runat="server" Text="Save
>Changes"></asp:Button></td>
></tr>
></table>
></FooterTemplate>
></asp:Repeater>
>
> public void Repeater1_ItemC ommand(object s, RepeaterCommand EventArgs e)
> {
> DropDownList ddl1 = (DropDownList)e .Item.FindContr ol("ddl");
>
> if(ddl1 !=null)
> {
> Response.Write( ddl1.SelectedIn dex.ToString()) ;
> }
> else
> {
> Response.Write( "ddl is null");
> }
> }