tags:

views:

124

answers:

3

I need immediate help. I have to create a class in asp.net 3.5. This class will take a dataset as input and have method in it that will populate dropdown list. The dataset has 5 columns. Based on column name passed as parameter to this method, the dropdown list will be populated with data in that column. Please add linq query to this method.

Please help me with linq query code ASAP.

region Public Methods

public DataSet DDLPopulate(String columnName)
{
    DataSet DSToReturn = new DataSet();
    //logic to filter based on the column NAme  - LINQ Query
    return DSToReturn;
}
+1  A: 

This might help you more. LINQ to DataSet Examples

Dustin Scaggs
I will have to use linq query, part of project policy. So please provide me the linq query code to extract unique data from dataset with specified column name. So if column name is business - I have to add linq query to extract data from dataset column "business" and return the extracted data as dataset. Please don't redirect me to different sites. I need help with the code.
menon
So, Im guessing you are using LINQ to SQL to get the data?
Dustin Scaggs
+1  A: 

Why go thru the effort of Linq2SQL, when you can simply use a DataAdapter?

leppie
I will have to use linq query project policy or rule. So please give me linq query code.
menon
YourDataContext.YourTable.INeedMoreInfo()
leppie
+1  A: 

You should've looked the examples in LINQ 101.

Anyways here's your query:

dropDownList.DataSource = from c in YourDataSet.Table.AsEnumerable()
                             select c.Field<string>("columnName");
dropDownList.DataBind();

Notice that the field type should be specified. So you should take care of that too.

Raúl Roa