0

How would I reference and pull data out of a generated dataset?

I have 2 projects in the same solution.

(1) MyUIProject

(2) MyDataSetProject ->MyGeneratedDataSet.xsd -->-->MyNamesTable (in the dataset)

All I want to do is reference the MyNamesTable and loop through the names in the table and put them in a list box. I'm having trouble getting the records out of the generated dataset.

I'm trying to do something like:

foreach (var name in MyDataSetProject.GeneratedDataSet.MyNamesTable)
{
    MyDropDownList.Items.Add(new ListItem(name));
}

Thanks for any thoughts.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
MissioDei
  • 809
  • 2
  • 12
  • 19
  • I think we would need to see more of the code to answer this question. For example, how are you currently referencing the `MyDataSetProject` in the `MyUIProject`? Have you defined a `datasource` for the `MyUIProject`? – Brian Mar 01 '13 at 16:56
  • are you using namespace in the current project also..? – MethodMan Mar 01 '13 at 17:00
  • MyUIProject is a website(not application) the MyDataSetProject is compiled and the .dll is located in the bin of the website. Is that what you are looking for? Sorry, I'm still pretty new at this and trying to modify someone else's work. – MissioDei Mar 01 '13 at 17:18

1 Answers1

0

First thing to do is make sure your references are correct between your projects. Right click on your MyUIProject and click Add Reference. Go to the Projects tab and add your MyDataSetProject entry. If it gives you an error about it already have been added, then it's already added.

Second, you need to access your dll project classes from your website. Let's say in your website you have a page called Default.aspx, and in your dll project you have a class called DataSetAccessor, which looks like the following:

public class DataSetAcessor
{
    public DataSet GetDataSet(<arguments>)
    {
        //populate the dataset and return it
    }
}

You can then use this class in your Default page:

//at top
using MyDataSetProject; //this may vary


//down in some method
DataSetAccessor dsa = new DataSetAccessor();
DataSet data = dsa.GetDataSet();

foreach(DataRow row in data.Tables[0].Rows)
{
    //using the values in row to populate your drop down list
}

Hopefully this help.

gunr2171
  • 16,104
  • 25
  • 61
  • 88