473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

The basics of repeater

I'm going to make a website where you can purchase stuff..
I'm having problems with the repeater. The problem is I dont know what to select in my repeater.

it's something like this
Expand|Select|Wrap|Line Numbers
  1. <table cellpadding="0" cellspacing="0">
  2. <tr valign="top" >
  3.     <td>Just nu har vi specialerbjudande på:
  4.     </td>
  5. </tr>
  6. <tr>
  7.  
  8.     <asp:Repeater ID="repeater" runat="server">
  9.  
  10.            <ItemTemplate>
  11.                   </tr>
  12.                   <tr>
  13.                         <td>
  14.                        <%#DataBinder.Eval(Container.DataItem,"gdname")%>                           
  15.                         </td>
  16.  
  17.                      <td>
  18.                             <asp:textbox id="Numbers" runat="server" />purchases
  19.                      </td>
  20.                </tr>
  21.                <tr>
  22.                      <td>
  23.                            <asp:button id="btn1" runat="server" text="Purchase" onclick="purchase" />      
  24.        </ItemTemplate>          
  25.     </asp:Repeater>
  26.  
  27.    </tr> 
  28. </table>
how do I get the information of wich goods they purshase? normally I would send a id with a label or something but all the labels on the site will have the same ID so the server wont know wich one to take the information from.

same goes for the button

so I just need the basics of how to use repeater, btw.. It seems I can't use labels inside the reapeter at all. can't find the id when writing, like it doesent exist at all

Thx =)
Apr 16 '09 #1
5 2411
Frinavale
9,735 Expert Mod 8TB
Well actually the ID of the Lables and Buttons within a Repeater all have unique IDs when they are rendered in the browser.

The Repeater's NamingContainer takes care of that.

To retrieve a Label or Button or Textbox (any control) from a repeater (or any other control that implements the INamingContinaer interface) you would use the FindControl() method.

All the information you need on Repeaters and any other .NET controls can be found in the MSDN Library. This resource should get you pointed in the right direction....there are multiple articles on theRepeaters there. I recommend bookmarking the MSDN Library and using it as your primary resource when developing in .NET.
Apr 16 '09 #2
Thx alot :D
now can I finally finnish my project :P
Apr 17 '09 #3
Only one problem =( dont know how to prevent this error to occur

CS0122: 'test.Button1_Click(object, System.EventArgs)' is inaccessible due to its protection level

I used:
Expand|Select|Wrap|Line Numbers
  1.  private void Button1_Click(object sender, EventArgs MyEventArgs)
  2.     {
  3.  
  4.         Control myControl1 = FindControl("numbers");
  5.         if (myControl1 != null)
  6.         {
  7.  
  8.             Control myControl2 = myControl1.Parent;
  9.             Response.Write("Parent of the text box is : " + myControl2.ID);
  10.         }
  11.         else
  12.         {
  13.             Response.Write("Control not found");
  14.         }
  15.     }
  16.  
any ideas? guess there's some settings I have to do?
Apr 17 '09 #4
to prevent this problem I changed it from private to public..

but I still got the problem I had earlier when pressing a button

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

that's the error I get, can anyone please help me?
Apr 17 '09 #5
sorry for making so many posts in this one and not doing the "[code]" around the code.

anyway, the only solution I have found so far is to use

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" EnableEventValidation="false" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" Title="Untitled Page" %>
  2.  
in the site. but by doing so I lower the security on the site. Not that it matters.

I also know that I can use ClientScriptManager.RegisterForEventValidation
but I dont know how this works and I can't seem to find any information about it.
anyone know?

just one more thing. I'm using
Expand|Select|Wrap|Line Numbers
  1.  private void Button1_Click(object sender, EventArgs MyEventArgs)
  2.      {
  3.  
  4.        Control myControl1 = FindControl("numbers");
  5.          if (myControl1 != null)
  6.          {
  7.  
  8.              Control myControl2 = myControl1.Parent;
  9.             Response.Write("Parent of the text box is : " + myControl2.ID);
  10.         }
  11.          else
  12.         {
  13.              Response.Write("Control not found");
  14.         }
  15.      }
but i always get the control not found. arent I supposed to write the ID in findcontrol?
Apr 17 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
0
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
2
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.