Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Nested Repeater Find Control on Button Click

Reply
Thread Tools

Nested Repeater Find Control on Button Click

 
 
stubsz stubsz is offline
Junior Member
Join Date: Nov 2009
Posts: 1
 
      11-13-2009
I am really stuck on this one!

I am pretty new to .NET so I'm creating a website as a project so that I can improve my knowledge. I have recently implemented a nested repeater on my page. The outer repeater brings back "headings" and the inner nested repeater brings back items related to the headings. Basically, I am using a nested repeater so that I can group my items e.g.

Heading 1
Item 1
Item 2
Item 3

Heading 2
Item 4
Item 5
Item 6

My code for the repeater looks like this:

-------------------------------------------------

<asp:Repeater ID="rptMenu" runat="server" DataSourceID="dsrc1">

<ItemTemplate>

<p><strong><asp:Label ID="lblSection" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"userm enu_type") %>'></asp:Label></strong></p>

<asp:Repeater runat="server" ID="rptChildMenu" DataSourceID="dsrc2">

<HeaderTemplate>

<table>

</HeaderTemplate>

<ItemTemplate>

<tr>

<td><asp:HiddenField ID="hdn_fieldreference" runat="server" value='<%#DataBinder.Eval(Container.DataItem,"user menu_field_reference") %>' /></td>

<td><asp:TextBox ID="tbox_menu" CssClass="inputFields" style="width: 200px;" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"userm enu_dishname") %>'></asp:TextBox></td>

<td>&nbsp;<asp:TextBox ID="tbox_price" CssClass="inputFields" style="width: 50px;" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"userm enu_price") %>'></asp:TextBox></td>

</tr>

</ItemTemplate>

<FooterTemplate>

</table>

</FooterTemplate>

</asp:Repeater>

<asp:SqlDataSource ID="dsrc2" runat="server" ConnectionString="<%$ ConnectionStrings:connString %>" SelectCommand="SELECT usermenu_dishname, usermenu_price, usermenu_type, usermenu_field_reference FROM tblUserMenu WHERE usermenu_user_reference = @Reference and usermenu_type = @Section">

<SelectParameters>

<asp:ControlParameter ControlID="lblSection" Name="Section" />

<asp:SessionParameter Name="Reference" SessionField="Reference" />

</SelectParameters>

</asp:SqlDataSource>

</ItemTemplate>

</asp:Repeater>

<asp:Button ID="btn1" runat="server" Text="Button" />

<asp:SqlDataSource ID="dsrc1" runat="server" ConnectionString="<%$ ConnectionStrings:connString %>" SelectCommand="SELECT DISTINCT usermenu_type FROM tblUserMenu WHERE (usermenu_user_reference = @Reference)">

<SelectParameters>

<asp:SessionParameter Name="Reference" SessionField="Reference" />

</SelectParameters>

</asp:SqlDataSource>

-------------------------------------------------


I have read some posts that relate to the outer repeater's ItemDataBound method and you have to bind the inner repeater? If I am using a SQLDataSource and passing in the SQL, then what would I pass in as the datasource? I am passing in the sql through the asp data source block as I need to be able to pass in the label's name so that I can get the items back based upon this so that I can group them (WHERE (usermenu_user_reference = @Reference))

What I have been attempting to do is to have a button, which is outside of the repeater, and when clicked, it will update values in the database. Problem is, I cannot get the FindControl method to work as I keep getting an "object reference not set" error in the button's click method. How do I access the textboxes in the nested repeater in this method? Can it be done?

Hopefully someone will have an idea of how this newbie can get this to work.

Any help will be appreciated.

BTW - I am using VB.

Cheers!
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
Repeater control with nested repeater chris.reed@digus.com ASP .Net 0 02-11-2005 05:10 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments