Click here to Skip to main content
11,641,209 members (64,877 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
i created my Select stored Procedyre
then i create a (LINQ to SQL class ) file .. drag and drop stored procedures to convert them into classes

i want to receive a column of table into a (drop down list)


Code in Page load
DataClass1DataContext countries = new DataClassesDataContext();


i do not know how to receive returned data into DropdownList

is it by using DataSeT ??!! and if it , how in code ?

thanks
Posted 8-Nov-12 15:23pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

take a dropdown list box
drag it in asp.net webpage i.e aspx page or design page

page load event write

load_dropdown()



then




Protected Sub load_dropdown()
        Dim sqlselect As String
        
            sqlselect = " SELECT columan_name FROM table_name "
            ds = Utility.ExecuteDataset(ConnectionString, CommandType.Text, sqlselect)
            ddlblockperiod.DataSource = ds
            ddlblockperiod.DataValueField = column_id;
            ddlblockperiod.DataTextField = column_name;
            ddlblockperiod.DataBind()
            ds.Dispose()
 
End Sub
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Var id=(from a in linq_obj.table name
Select new
{
Intglcode=a.intglcode,
columnname =a.columnname
}).Tolist();
ddlblockperiod.Datasource=id;
ddlblockperiod.DataValueField = column_id;
ddlblockperiod.DataTextField = column_name;
ddlblockperiod.Databind();

try this...........
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

DOne Smile | :)



protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataClassesDataContext countries = new DataClassesDataContext();
            DropDownList1.DataSource = countries.SelectCountries();
            DropDownList1.DataTextField = "CountryName";
            DropDownList1.DataBind();
        }
    }


As
DataClassesDataContext
>>> is a Link to SQL Classes
&
SelectCountries
>>>> is a class in
DataClassesDataContext
, that Select all countries from countries table
&
CountryName
>>> is the selected column from countries table


Thanks all for answers Smile | :)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100