473,326 Members | 2,114 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,326 software developers and data experts.

Populate DropDownList inside Repeater under Page_load()

Hi
I am trying to place three DropDownLists inside a Repeater, each DLL is dependent on it’s previous DDL’s selection. I’m developing in asp.net and VB.
An Initial DDL (inside the repeater) needs to be populated under Page_load () through a stored proc, the selection from this needs to fire another stored proc and populate it’s child DDL. My main concern at this moment is how to populate the first DDL under page_load. I am able to do this outside the repeater but not within it. I’m a new developer exact syntax is my huge weakness, many thanks in advance.
Dec 4 '07 #1
2 9309
nateraaaa
663 Expert 512MB
You will need to use the IteamDataBound event of the repeater to populate the dropdownlist inside of your repeater. Use the following code:

Expand|Select|Wrap|Line Numbers
  1. DropDownList ddl = (DropDownList)e.Item.FindControl("nameofyourddl");
  2. DataSet ds = new DataSet();
  3. //call your stored procedure then fill the dataset with the results
  4. oDataAdapter.Fill(ds );
  5. //now use the dataset as the datasource for your dropdownlist
  6. ddl.DataSource = ds;
  7. ddl.DataTextField = "columnofdatasetyouwantdisplayedinddl";
  8. ddl.DataValueField = "columnofdatasetyouwantasvalue";
  9. ddl.DataBind();
Now in the selectedindexchanged event of your dropdownlist your can autopopulate additional dropdownlist with values. You will need to be sure that the AutoPostBack property of each preceding dropdownlist is set to true. If you are using AJAX to autopopulate the additional dropdownlists this may not be the case.

Nathan
Dec 4 '07 #2
Hi Nathan
Thanks for your help, that worked great, my method is below. it seems to compile so I’m guessing it will work, Unfortunately I cannot seem to see the repeater control when I preview my page (visable property is set to "true"), does this have something to do with the method not being called under page_load(), again some sample code will be great help. Thanks in advance!!

Khuram

Public Sub populateRpt_ItemDataBound(ByVal Sender As Object, ByVal e As RepeaterItemEventArgs)
Dim ddl As DropDownList = DirectCast(e.Item.FindControl("ddlJobCode2"), DropDownList)
Dim ds As New DataSet()
Dim daJobCode As New SqlDataAdapter()
'call your stored procedure then fill the dataset with the results
daJobCode.Fill(ds)
'now use the dataset as the datasource for your dropdownlist
ddl.DataSource = ds
ddl.DataTextField = "jobcode"
ddl.DataValueField = "jobcode"
ddl.DataBind()
End Sub
Dec 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Darren | last post by:
Hi There, I am developing a shopping cart web application in C#. Product pricing for an item changes based on the weight of product purchased. ie: 100g=$4.95, 200g=$7.95, etc. Pricing is...
2
by: huzz | last post by:
How do i make a dropdownlist selected value based on the value i retrive from the database. Basically i have an edit page and like to display the default value in a dropdown list from the...
1
by: Joe Gass | last post by:
I'd like to bind some xml to a dropdownlist <engines> <engine name="test1" id="1" /> <engine name="test2" id="2" /> </engines> If I do: ddlEngines.DataSource =...
3
by: Ben Dewey | last post by:
Hey everyone, I have a wierd issue i can't seem to find out whats going on. I have a Control for a Shopping Cart Merchant Page called OrderStatus.ascx Inside that control there is a Repeater...
4
by: jjack100 | last post by:
I have a DropDownList that is nested inside a Repeater. The datasource of the DropDownList is declared in the aspx, not the codebehind. So we have this: <asp:Repeater ID="rptOptions"...
1
by: Jeremy | last post by:
Hello All, I have a Repeater which contains a Dynamic DropDownList within its itemtemplate. I know I have struggled with this before and I am pretty sure I had to save a bunch of crap manually...
1
by: Eugene Anthony | last post by:
ModifyUserRegistration.aspx --------------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModifyUserRegistration.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC...
3
by: gsauns | last post by:
Hello, I have an ASP.NET app with a DropDownList on the page, which is bound to values from a table. I have a Repeater control on the page whose displayed data is dependent on the DropDownList...
2
by: MattB | last post by:
I have a (.Net 1.1) form with a Repeater and a DropDownList in the ItemTemplate. I programmatically make the DDL Autopostback = true at runtime based on the bound data. That works - I can see the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.