ASP.NET dataset

  • Thread starter Thread starter somersbar
  • Start date Start date
S

somersbar

hi,
i need to create a new dataset at runtime in a button event handler.
can anyone start me off in the right direction?
 
actually,
i have 2 datasets and 2 dropdownlists on my webform. wen a value is
selected from the 1st dropdownlist, i need to populate the 2nd
dropdownlist with values from the 2nd dataset that have a property
corresponding to the value selected from the 1st dropdownlist.
where do i start?
 
DataSet.Select

While you might put the "autopostback" to true on the first drop down, I
usually put a linkbutton next to it, which says "Go"

In the code of the Go button.... you will find the value of the key you are
using.

EX:

Your first ddl has States. When they pick a state, you filter the second
ddl with Counties.

use the ddl.SelectedItem.Value property to get the state abbr (like "NC")

On the second dataset, run a

ddlCounties.DataSource = ds2.Counties.Select("StateName = '" +
myVarWithTheStateInItFromDDL1 + "'", "CountyName);
ddlCounties.DataBind

that will get you started.
 
If you're using 1.1, then use my suggestion.

If you're at 2.0, then go with Peter's.

Since you didn't specify, I put the way that works with 1.1, and can work
with 2.0, its just not quite a clean as it could be with the new objects in
2.0.

...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top