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

Drop down list inside a repeater

Hi

I'm trying to have a drop down list inside a repeater
where the data for the list is extracted from a database
along with other items but I can't seem to get it to work
for the list.

My html is as follows:
<asp:panel id="Panel1" style="Z-INDEX: 104; LEFT: 240px;
POSITION: absolute; TOP: 184px" runat="server"
Height="386px" Width="594px">
<asp:Repeater id="TaskRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="594">
<tr>
<td align="left">Task</td>
<td align="left">Project</td>
<td align="left">Language</td>
<td align="center">Progress</td>
<td align="left">Wordcount</td>
<td align="left">Assignee</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"TASK_NAME") %>
</td>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"PROJECT_NAME") %>
</td>
<td width="150">
<asp:DropDownList id="LanguageDropDownList"
DataTextField="LANG_NAME"
style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute; TOP:
30px"
runat="server" Height="18px"
Width="74px"></asp:DropDownList>
What's happening is that I get TASK_NAME,PROJECT_NAME out
ok (although they are repeated for each LANG_NAME) but I
cannot get anything for LANG_NAME. I know that LANG_NAME
is being extracted correctly from the database since if I
exchange PROJECT_NAME for LANG_NAME in the code above then
I get the languages ok.

I can't find much info./samples on this type of thing -
can anyone help?

Thanks in advance.
Nov 18 '05 #1
2 7854
I did what you are trying to do binding the dropdownlist
with another datatable, not with the data that the
repeater is binded with.

To do this I overwrited the repeater method
onItemDataBound for the corresponding event.

Important: If you just want to bind the dropdownlist, this
works, but with you want to do something like select an
item you will have some trouble.

By this moment that's all I can say about this subject...

good luck
Goncalo
-----Original Message-----
Hi

I'm trying to have a drop down list inside a repeater
where the data for the list is extracted from a database
along with other items but I can't seem to get it to work
for the list.

My html is as follows:
<asp:panel id="Panel1" style="Z-INDEX: 104; LEFT: 240px;
POSITION: absolute; TOP: 184px" runat="server"
Height="386px" Width="594px">
<asp:Repeater id="TaskRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="594">
<tr>
<td align="left">Task</td>
<td align="left">Project</td>
<td align="left">Language</td>
<td align="center">Progress</td>
<td align="left">Wordcount</td>
<td align="left">Assignee</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"TASK_NAME") %>
</td>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"PROJECT_NAME") %>
</td>
<td width="150">
<asp:DropDownList id="LanguageDropDownList"
DataTextField="LANG_NAME"
style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute; TOP:30px"
runat="server" Height="18px"
Width="74px"></asp:DropDownList>
What's happening is that I get TASK_NAME,PROJECT_NAME out
ok (although they are repeated for each LANG_NAME) but I
cannot get anything for LANG_NAME. I know that LANG_NAME
is being extracted correctly from the database since if I
exchange PROJECT_NAME for LANG_NAME in the code above thenI get the languages ok.

I can't find much info./samples on this type of thing -
can anyone help?

Thanks in advance.
.

Nov 18 '05 #2
Hi Rona,

here is a way of doing it you can catch the event ItemDataBound so you would
have a line of code like this
this.TaskRepeater.ItemDataBound += new
System.Web.UI.WebControls.RepeaterItemEventHandler (this.TaskRepeater_ItemBou
nd);

and then in the you would have to add the method below

private void DataGrid1_ItemBound(object sender, DataGridItemEventArgs e){

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem){

DropDownList =
(DropDownList)e.Item.FindControl("LanguageDropDown List");

//here you loop trough the languages to add them
somthing similar to this

DropDownList.Items.Add(new ListItem("name","value"));

}

}

the code above isn't tested or compiled i just wrote it of the top of my
head maybe if you provide more about how you bind the repeater to the
database I would be able to give you more details.

Cheers

Tim

<ro**@discussions.microsoft.com> wrote in message
news:cf****************************@phx.gbl...
Hi

I'm trying to have a drop down list inside a repeater
where the data for the list is extracted from a database
along with other items but I can't seem to get it to work
for the list.

My html is as follows:
<asp:panel id="Panel1" style="Z-INDEX: 104; LEFT: 240px;
POSITION: absolute; TOP: 184px" runat="server"
Height="386px" Width="594px">
<asp:Repeater id="TaskRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="594">
<tr>
<td align="left">Task</td>
<td align="left">Project</td>
<td align="left">Language</td>
<td align="center">Progress</td>
<td align="left">Wordcount</td>
<td align="left">Assignee</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"TASK_NAME") %>
</td>
<td width="150">
<%# DataBinder.Eval(Container.DataItem,"PROJECT_NAME") %>
</td>
<td width="150">
<asp:DropDownList id="LanguageDropDownList"
DataTextField="LANG_NAME"
style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute; TOP:
30px"
runat="server" Height="18px"
Width="74px"></asp:DropDownList>
What's happening is that I get TASK_NAME,PROJECT_NAME out
ok (although they are repeated for each LANG_NAME) but I
cannot get anything for LANG_NAME. I know that LANG_NAME
is being extracted correctly from the database since if I
exchange PROJECT_NAME for LANG_NAME in the code above then
I get the languages ok.

I can't find much info./samples on this type of thing -
can anyone help?

Thanks in advance.

Nov 18 '05 #3

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

Similar topics

1
by: Dec | last post by:
Ok to simplify things I'll just give an example. This is pretty much what I want to do (minus the postcode): http://www.perrys.co.uk/usedcar?ID=F5J9BNNBMVK00DF I have relatively little...
1
by: Timothy V | last post by:
Hi, If i have an array of arrays (ie, array of int arrays), and i want to use a repeater (for the array) that has a drop down list (for the int arrays), how do I do it? Thank you very much in...
0
by: BryanS | last post by:
I am having trouble trying to link 2 drop down lists and a repeater control. What i want is 2 drop down lists, the first being a list of food categories. When a category is selected the second...
5
by: Grant Merwitz | last post by:
How do you unbind one of these web controls. I have a drop down list that based on another drop down list selection will be databouns private void BindDD2(int id) { DD2.DataSource =...
4
by: Chris Kettenbach | last post by:
Good Morning, Quick question, I have an EditItemTemplate inside a datagrid. It should contain a drop down list of possible choices. I have an EditCommandColumn. The drop dow list column should...
0
by: dutone | last post by:
I have searched high and low for a solution to this and I dont think its possible.... but I hope not. What I have is a list of items with various values that can be changed via a drop down. Each...
0
by: Pradeep | last post by:
Hi, Would some lead me to/through an example for adding a drop down list to a repeater control in a web page. Also with details on how to handle the SelectedItem event of the drop down list. ...
1
by: champ.supernova | last post by:
Hi, I have a dropdownlist which is repeated inside a repeater. What I'm wanting is for when one instance of the dropdownlist has its selection changed, for 1) this to trigger an...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.