473,385 Members | 1,641 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,385 software developers and data experts.

repeater and databinding (postback)

Hi all,

I have a repaeter rendering textboxes. I also attach a datascource
(array) to the repeater with default valeus:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] list = {"string1", "string2", "string3", "string4",
"string5"};
Repeater1.DataSource = list;
Repeater1.DataBind();
}
}

A user can change the content of the 5 textboxes and when he clicks the
sublit button I want to read out the data from the textboxes and put it
into a string array:
protected void Button_Click(object sender, EventArgs e)
{
string[] list = Repeater1.DataSource as string[];
}

The problem is that the datasource is null and thus also the list
string. I only attach a datasource at not postback. I don't know how I
can attach a datasource, which is the user input to the repeater, at
postback.

Help is greatly appreciated.

Thanks in advance
Stijn

Oct 11 '06 #1
1 8702
The DataSource won't survive a postback intact - even with viewstate on.

You need to loop through the Repeater, find each textbox and get it's value.
foreach (RepeaterItem item in Repeater1.Items)
{
if (item.ItemType == ItemType.Item || item.ItemType ==
ItemType.AlternatingItem)
{
TextBox txt = (TextBox)item.FindControl("TextboxId");
//now you can get the txt.Text and do stuff
}
}

The above code is just a rough go at it.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
<ta******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hi all,

I have a repaeter rendering textboxes. I also attach a datascource
(array) to the repeater with default valeus:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] list = {"string1", "string2", "string3", "string4",
"string5"};
Repeater1.DataSource = list;
Repeater1.DataBind();
}
}

A user can change the content of the 5 textboxes and when he clicks the
sublit button I want to read out the data from the textboxes and put it
into a string array:
protected void Button_Click(object sender, EventArgs e)
{
string[] list = Repeater1.DataSource as string[];
}

The problem is that the datasource is null and thus also the list
string. I only attach a datasource at not postback. I don't know how I
can attach a datasource, which is the user input to the repeater, at
postback.

Help is greatly appreciated.

Thanks in advance
Stijn

Oct 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
6
by: Christoph Boget | last post by:
Could someone point me to a resource that discusses how to set up other controls (input box, checkbox, drop down list), etc to be used in a Repeater? I'm not having a problem displaying text in...
4
by: bob garbados | last post by:
I need to create a page that displays all of the products from a table and allows for add to cart functionality. My thoughts were to display all of the products in table rows using a repeater. ...
1
by: Alan Silver | last post by:
Hello, I have a page in which I'm trying to give the user the chance to manipulate a list of items. These are the price variations for a product, so each item consists of a name (eg, small,...
1
by: Andy | last post by:
team, my postback is changing once i bind an arraylist to a repeater. how can i get the postback to return true? ''''''''''''''''''''''''''''''''''''''''' 'declarations
4
by: jim.long | last post by:
I can't seem to get the checked value from the checkboxes! Is there something wrong with the code? It loops through the repeater item collection correctly. HTML: <asp:repeater id="rPrinterJobs"...
2
by: Andy Fish | last post by:
Hi, I have a forrm with viewstate disabled (to try and optimize network performance). I have come a bit unstuck though when I use a repeater with a textbox inside it Obivously with viewstate...
3
by: musosdev | last post by:
Hi guys I have a Repeater that I'm databinding to an OleDBDataReader which has the SQL... SELECT TOP 2 ... WHERE... ORDER BY ... But I don't actually want the top 2.. I want the 3rd and 4th...
2
by: Wizzard | last post by:
I have a repeater with and imagebutton on a page useing VS2005 ASP.Net 2.0 <asp:Repeater ID="Repeater1" runat="server" > <ItemTemplate> <div> <asp:ImageButton ImageUrl="button.gif"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.