Click here to Skip to main content
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 16: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 Sergey Alexandrovich Kryukov 425
1 OriginalGriff 165
2 DamithSL 130
3 Dave Kreskowiak 120
4 Suvendu Shekhar Giri 110
0 OriginalGriff 7,645
1 DamithSL 5,614
2 Sergey Alexandrovich Kryukov 5,344
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
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