473,385 Members | 1,973 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.

Getting data out of the Repeater Web Control

Hello -

I'm using a Repeater control to render information in a very customized
grid-like table. The Repeater control is binded to a DataSet with several
records of information. Within the Repeater control, I've placed
DropDownLists and CheckBoxes.

When the user has updated the information, he/he clicks the submit button
which is outside the scope of the Repeater control.

What i need to do, is read each of the values from DropDownLists and
CheckBoxes and save these into the database. How can i read these controls
from code-behind?

I was thinking of using:

foreach (Control ctr in Page.Controls)
{
if (ctr is DropDownList)
{
// do something
}
}

However, i cannot find the repeater control. Any ideas how to do this?

Thanks,
Nov 19 '05 #1
7 5457
You can loop through the repeater Items collection, find the ddls and
checkboxes with the item's FindControl method, get the values, set them in
the dataset table and at the end call the Update method of the data adapter
that links the dataset to the database.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Hello -

I'm using a Repeater control to render information in a very customized
grid-like table. The Repeater control is binded to a DataSet with several
records of information. Within the Repeater control, I've placed
DropDownLists and CheckBoxes.

When the user has updated the information, he/he clicks the submit button
which is outside the scope of the Repeater control.

What i need to do, is read each of the values from DropDownLists and
CheckBoxes and save these into the database. How can i read these controls
from code-behind?

I was thinking of using:

foreach (Control ctr in Page.Controls)
{
if (ctr is DropDownList)
{
// do something
}
}

However, i cannot find the repeater control. Any ideas how to do this?

Thanks,

Nov 19 '05 #2
Thanks, but in my scenario, this is not possible. My custom-grid created with
the repeater controls, comprises, several different DataSets as well as
unique info from constants, session vars, etc... Hence, i need to be able to
loop through the controls collection. Any ideas?

Thanks again,

"Eliyahu Goldin" wrote:
You can loop through the repeater Items collection, find the ddls and
checkboxes with the item's FindControl method, get the values, set them in
the dataset table and at the end call the Update method of the data adapter
that links the dataset to the database.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Hello -

I'm using a Repeater control to render information in a very customized
grid-like table. The Repeater control is binded to a DataSet with several
records of information. Within the Repeater control, I've placed
DropDownLists and CheckBoxes.

When the user has updated the information, he/he clicks the submit button
which is outside the scope of the Repeater control.

What i need to do, is read each of the values from DropDownLists and
CheckBoxes and save these into the database. How can i read these controls
from code-behind?

I was thinking of using:

foreach (Control ctr in Page.Controls)
{
if (ctr is DropDownList)
{
// do something
}
}

However, i cannot find the repeater control. Any ideas how to do this?

Thanks,


Nov 19 '05 #3
Your original question refers to just one repeater. Do you mean you have
nested repeaters? You can always get to any single one of them and then loop
through its items.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Thanks, but in my scenario, this is not possible. My custom-grid created with the repeater controls, comprises, several different DataSets as well as
unique info from constants, session vars, etc... Hence, i need to be able to loop through the controls collection. Any ideas?

Thanks again,

"Eliyahu Goldin" wrote:
You can loop through the repeater Items collection, find the ddls and
checkboxes with the item's FindControl method, get the values, set them in the dataset table and at the end call the Update method of the data adapter that links the dataset to the database.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Hello -

I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the Repeater control, I've placed
DropDownLists and CheckBoxes.

When the user has updated the information, he/he clicks the submit button which is outside the scope of the Repeater control.

What i need to do, is read each of the values from DropDownLists and
CheckBoxes and save these into the database. How can i read these controls from code-behind?

I was thinking of using:

foreach (Control ctr in Page.Controls)
{
if (ctr is DropDownList)
{
// do something
}
}

However, i cannot find the repeater control. Any ideas how to do this?

Thanks,


Nov 19 '05 #4
First, thanks Eliyahu for your help.

I don't have nested repeaters, i am only using one. I do have other nested
controls, specifically the DropDownList and CheckBox. The Submit Button is
not part of the Repeater control.

I am assuming that you suggest taht i use the Repeater.Controls collection
to loop?

"Eliyahu Goldin" wrote:
Your original question refers to just one repeater. Do you mean you have
nested repeaters? You can always get to any single one of them and then loop
through its items.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Thanks, but in my scenario, this is not possible. My custom-grid created

with
the repeater controls, comprises, several different DataSets as well as
unique info from constants, session vars, etc... Hence, i need to be able

to
loop through the controls collection. Any ideas?

Thanks again,

"Eliyahu Goldin" wrote:
You can loop through the repeater Items collection, find the ddls and
checkboxes with the item's FindControl method, get the values, set them in the dataset table and at the end call the Update method of the data adapter that links the dataset to the database.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
> Hello -
>
> I'm using a Repeater control to render information in a very customized > grid-like table. The Repeater control is binded to a DataSet with several > records of information. Within the Repeater control, I've placed
> DropDownLists and CheckBoxes.
>
> When the user has updated the information, he/he clicks the submit button > which is outside the scope of the Repeater control.
>
> What i need to do, is read each of the values from DropDownLists and
> CheckBoxes and save these into the database. How can i read these controls > from code-behind?
>
> I was thinking of using:
>
> foreach (Control ctr in Page.Controls)
> {
> if (ctr is DropDownList)
> {
> // do something
> }
> }
>
> However, i cannot find the repeater control. Any ideas how to do this?
>
> Thanks,


Nov 19 '05 #5
Hi Charliewest,

loop through the repeater.items collection
HTH jd

For Each item As RepeaterItem In rep.Items

If item.ItemIndex > -1 Then

Dim myVal As String

' this assumes you do not know the id of the control
' if you do use then item.FindControl(controlId)
' also if the repeateritem contains more than one checkbox
' or more than one dropdown list you will be left with the
value of the
' last control examined.... but you should get the idea...

For Each con As Control In item.Controls

If TypeOf con Is DropDownList Then

myVal = CType(con, DropDownList).SelectedValue

ElseIf TypeOf con Is CheckBox Then

If CType(con, CheckBox).Checked Then

myVal = CType(con, CheckBox).Text

End If

Else

'do nothing

End If
Next
End If

Next
"charliewest" wrote:
First, thanks Eliyahu for your help.

I don't have nested repeaters, i am only using one. I do have other nested
controls, specifically the DropDownList and CheckBox. The Submit Button is
not part of the Repeater control.

I am assuming that you suggest taht i use the Repeater.Controls collection
to loop?

"Eliyahu Goldin" wrote:
Your original question refers to just one repeater. Do you mean you have
nested repeaters? You can always get to any single one of them and then loop
through its items.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Thanks, but in my scenario, this is not possible. My custom-grid created

with
the repeater controls, comprises, several different DataSets as well as
unique info from constants, session vars, etc... Hence, i need to be able

to
loop through the controls collection. Any ideas?

Thanks again,

"Eliyahu Goldin" wrote:

> You can loop through the repeater Items collection, find the ddls and
> checkboxes with the item's FindControl method, get the values, set them

in
> the dataset table and at the end call the Update method of the data

adapter
> that links the dataset to the database.
>
> Eliyahu
>
> "charliewest" <ch*********@discussions.microsoft.com> wrote in message
> news:B6**********************************@microsof t.com...
> > Hello -
> >
> > I'm using a Repeater control to render information in a very

customized
> > grid-like table. The Repeater control is binded to a DataSet with

several
> > records of information. Within the Repeater control, I've placed
> > DropDownLists and CheckBoxes.
> >
> > When the user has updated the information, he/he clicks the submit

button
> > which is outside the scope of the Repeater control.
> >
> > What i need to do, is read each of the values from DropDownLists and
> > CheckBoxes and save these into the database. How can i read these

controls
> > from code-behind?
> >
> > I was thinking of using:
> >
> > foreach (Control ctr in Page.Controls)
> > {
> > if (ctr is DropDownList)
> > {
> > // do something
> > }
> > }
> >
> > However, i cannot find the repeater control. Any ideas how to do this?
> >
> > Thanks,
>
>
>


Nov 19 '05 #6
This is perfect. Thanks. My code in C# for those who might be interested is:

// Get Data out of Repeater Control
System.Collections.ArrayList ar_Status = new ArrayList();
System.Collections.ArrayList ar_CheckBox = new ArrayList();
foreach (RepeaterItem item in Repeater1.Items)
{
if (item.ItemIndex > -1)
{
foreach (Control ctr in item.Controls)
{
if (ctr is DropDownList)
{
ar_Status.Add(((DropDownList)ctr).SelectedValue);
}
else if (ctr is CheckBox)
{
ar_CheckBox.Add(((CheckBox)ctr).Checked);
}
}
}
}

"london calling" wrote:
Hi Charliewest,

loop through the repeater.items collection
HTH jd

For Each item As RepeaterItem In rep.Items

If item.ItemIndex > -1 Then

Dim myVal As String

' this assumes you do not know the id of the control
' if you do use then item.FindControl(controlId)
' also if the repeateritem contains more than one checkbox
' or more than one dropdown list you will be left with the
value of the
' last control examined.... but you should get the idea...

For Each con As Control In item.Controls

If TypeOf con Is DropDownList Then

myVal = CType(con, DropDownList).SelectedValue

ElseIf TypeOf con Is CheckBox Then

If CType(con, CheckBox).Checked Then

myVal = CType(con, CheckBox).Text

End If

Else

'do nothing

End If
Next
End If

Next
"charliewest" wrote:
First, thanks Eliyahu for your help.

I don't have nested repeaters, i am only using one. I do have other nested
controls, specifically the DropDownList and CheckBox. The Submit Button is
not part of the Repeater control.

I am assuming that you suggest taht i use the Repeater.Controls collection
to loop?

"Eliyahu Goldin" wrote:
Your original question refers to just one repeater. Do you mean you have
nested repeaters? You can always get to any single one of them and then loop
through its items.

Eliyahu

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
> Thanks, but in my scenario, this is not possible. My custom-grid created
with
> the repeater controls, comprises, several different DataSets as well as
> unique info from constants, session vars, etc... Hence, i need to be able
to
> loop through the controls collection. Any ideas?
>
> Thanks again,
>
> "Eliyahu Goldin" wrote:
>
> > You can loop through the repeater Items collection, find the ddls and
> > checkboxes with the item's FindControl method, get the values, set them
in
> > the dataset table and at the end call the Update method of the data
adapter
> > that links the dataset to the database.
> >
> > Eliyahu
> >
> > "charliewest" <ch*********@discussions.microsoft.com> wrote in message
> > news:B6**********************************@microsof t.com...
> > > Hello -
> > >
> > > I'm using a Repeater control to render information in a very
customized
> > > grid-like table. The Repeater control is binded to a DataSet with
several
> > > records of information. Within the Repeater control, I've placed
> > > DropDownLists and CheckBoxes.
> > >
> > > When the user has updated the information, he/he clicks the submit
button
> > > which is outside the scope of the Repeater control.
> > >
> > > What i need to do, is read each of the values from DropDownLists and
> > > CheckBoxes and save these into the database. How can i read these
controls
> > > from code-behind?
> > >
> > > I was thinking of using:
> > >
> > > foreach (Control ctr in Page.Controls)
> > > {
> > > if (ctr is DropDownList)
> > > {
> > > // do something
> > > }
> > > }
> > >
> > > However, i cannot find the repeater control. Any ideas how to do this?
> > >
> > > Thanks,
> >
> >
> >

Nov 19 '05 #7
Did that soultion work for you? I am stuck on the DropDownList being cleared
out on PostBack because the ItemCreated event isnt being called after the
original databind. but if I do the databind then I lose all of the users
changes.

Any ideas?
"charliewest" wrote:
This is perfect. Thanks. My code in C# for those who might be interested is:

// Get Data out of Repeater Control
System.Collections.ArrayList ar_Status = new ArrayList();
System.Collections.ArrayList ar_CheckBox = new ArrayList();
foreach (RepeaterItem item in Repeater1.Items)
{
if (item.ItemIndex > -1)
{
foreach (Control ctr in item.Controls)
{
if (ctr is DropDownList)
{
ar_Status.Add(((DropDownList)ctr).SelectedValue);
}
else if (ctr is CheckBox)
{
ar_CheckBox.Add(((CheckBox)ctr).Checked);
}
}
}
}

"london calling" wrote:
Hi Charliewest,

loop through the repeater.items collection
HTH jd

For Each item As RepeaterItem In rep.Items

If item.ItemIndex > -1 Then

Dim myVal As String

' this assumes you do not know the id of the control
' if you do use then item.FindControl(controlId)
' also if the repeateritem contains more than one checkbox
' or more than one dropdown list you will be left with the
value of the
' last control examined.... but you should get the idea...

For Each con As Control In item.Controls

If TypeOf con Is DropDownList Then

myVal = CType(con, DropDownList).SelectedValue

ElseIf TypeOf con Is CheckBox Then

If CType(con, CheckBox).Checked Then

myVal = CType(con, CheckBox).Text

End If

Else

'do nothing

End If
Next
End If

Next
"charliewest" wrote:
First, thanks Eliyahu for your help.

I don't have nested repeaters, i am only using one. I do have other nested
controls, specifically the DropDownList and CheckBox. The Submit Button is
not part of the Repeater control.

I am assuming that you suggest taht i use the Repeater.Controls collection
to loop?

"Eliyahu Goldin" wrote:

> Your original question refers to just one repeater. Do you mean you have
> nested repeaters? You can always get to any single one of them and then loop
> through its items.
>
> Eliyahu
>
> "charliewest" <ch*********@discussions.microsoft.com> wrote in message
> news:76**********************************@microsof t.com...
> > Thanks, but in my scenario, this is not possible. My custom-grid created
> with
> > the repeater controls, comprises, several different DataSets as well as
> > unique info from constants, session vars, etc... Hence, i need to be able
> to
> > loop through the controls collection. Any ideas?
> >
> > Thanks again,
> >
> > "Eliyahu Goldin" wrote:
> >
> > > You can loop through the repeater Items collection, find the ddls and
> > > checkboxes with the item's FindControl method, get the values, set them
> in
> > > the dataset table and at the end call the Update method of the data
> adapter
> > > that links the dataset to the database.
> > >
> > > Eliyahu
> > >
> > > "charliewest" <ch*********@discussions.microsoft.com> wrote in message
> > > news:B6**********************************@microsof t.com...
> > > > Hello -
> > > >
> > > > I'm using a Repeater control to render information in a very
> customized
> > > > grid-like table. The Repeater control is binded to a DataSet with
> several
> > > > records of information. Within the Repeater control, I've placed
> > > > DropDownLists and CheckBoxes.
> > > >
> > > > When the user has updated the information, he/he clicks the submit
> button
> > > > which is outside the scope of the Repeater control.
> > > >
> > > > What i need to do, is read each of the values from DropDownLists and
> > > > CheckBoxes and save these into the database. How can i read these
> controls
> > > > from code-behind?
> > > >
> > > > I was thinking of using:
> > > >
> > > > foreach (Control ctr in Page.Controls)
> > > > {
> > > > if (ctr is DropDownList)
> > > > {
> > > > // do something
> > > > }
> > > > }
> > > >
> > > > However, i cannot find the repeater control. Any ideas how to do this?
> > > >
> > > > Thanks,
> > >
> > >
> > >
>
>
>

Jun 8 '06 #8

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

Similar topics

2
by: John Holmes | last post by:
I am using radioButton controls in a data repeater and would like to incorporate the 'key' field into the 'id' attribute of the radioButton controls and name them something like: 'rad' + '<%#...
2
by: Steve | last post by:
Hi All I am trying to find a way of displaying data in a datatable in such a way that ALL rows (only about 5 - 10) are editable and are updated from a single button press. I thought the best way...
8
by: darrel | last post by:
*sigh*...I've asked this before, but have long forgotten the answer. In the past, I'd often use repeater controls, bind data to it, and then reference the data fields from within the repeater: ...
1
by: Greg Cyrus | last post by:
Hi, i have created a function to open a Databse by OLEDB and fill it into a System.Data.DataSet-Objekt by oleDBAdapter.Fill-Mehtod.. Now I want to assign this DataSet to a normal...
3
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
0
by: warren_rapson | last post by:
Hi all, I am a newbie to this awesome framework - i love it. My situation: - I have a master page with a menu on it and a ContenPlaceHolder containing a DataList - The menu is dynamic and is...
2
by: AC [MVP MOSS] | last post by:
I have a repeater with a header, footer, and item template. The item template is the only one with server controls (hyperlinks, labels, and a nested repeater). Within the top repeater, I'm handling...
3
by: Emma Middlebrook | last post by:
Hi there, I've been trying to implement a repeater control in an ASP.NET 2 page but I can't seem to get the layout exactly how I want and I'm not sure if it's something that I am doing wrong or...
7
by: jaffarkazi | last post by:
Hi all, I'm developing a site. One of the features is a search page, for which I'm using a data repeater control. For the rest of the pages it is fine, but, obviously, on the search page, for...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.