Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Drop down list inside a repeater

Reply
Thread Tools

Drop down list inside a repeater

 
 
Guest
Posts: n/a
 
      12-04-2003
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:
<aspanel 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">
<aspropDownList id="LanguageDropDownList"
DataTextField="LANG_NAME"
style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute; TOP:
30px"
runat="server" Height="18px"
Width="74px"></aspropDownList>


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.
 
Reply With Quote
 
 
 
 
Goncalo
Guest
Posts: n/a
 
      12-05-2003
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:
><aspanel 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">
><aspropDownList id="LanguageDropDownList"
>DataTextField="LANG_NAME"
>style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute;

TOP:
>30px"
>runat="server" Height="18px"
>Width="74px"></aspropDownList>
>
>
>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.
>.
>

 
Reply With Quote
 
 
 
 
Hatim R
Guest
Posts: n/a
 
      12-05-2003
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

<(E-Mail Removed)> wrote in message
news:cf4e01c3ba82$1bb271a0$(E-Mail Removed)...
> 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:
> <aspanel 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">
> <aspropDownList id="LanguageDropDownList"
> DataTextField="LANG_NAME"
> style="Z-INDEX: 101; LEFT: 205px; POSITION: absolute; TOP:
> 30px"
> runat="server" Height="18px"
> Width="74px"></aspropDownList>
>
>
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Firing events from drop down list INSIDE a repeater? champ.supernova@gmail.com ASP .Net 1 05-14-2007 12:06 PM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments