Click here to Skip to main content
14,770,794 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!


I have a repeater control displays the ProductCode in line1, ProductDescription in Line2 and ProductRRP in Line3 all in one column.

I need to loop through this repeater and save the entries to sql.

How can I loop through this repeater and get the values so that I can assign them to the stored procedure params in order to insert?

Thank you!!

P.S - I tried pasting some code but the "code block" does not work. It removes more than half on the code.
Posted

Is this in ASP.Net?

If not, ignore the rest of this. If so, then you may be better off taking the data from the repeaters datasource. However, if you must read the values from the controls within the repeater you can access the 'Items' property on the instance and which will contain a reference to all of the child controls.

You can then simply find the control you want (probably and Label or Literal) and take the value.

Of course, for this to work your repeater will need to be able to persist the data you want through a post back operation.
   
In ASP.Net, you can use this code for iterate through Repeater Items

foreach (RepeaterItem item in Repeater1.Items)
{
  // find controls in Repeater and assign values to parameters like

  Label label1 = (Label) item.FindControl("controlname");

  // call the insert function inside the loop.
}
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900