Hi,
Could someone tell me how can be populated DropdownList from Data Base. I
use ASP.NET/C#/MS SQL SERVER.
Thanks!
Viktor
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.Victor,
You need to get the database data into a dataset, set the DropdownList
properties DataSource to the dataset name and DataMember to the table name
and call DataBind method.
Eliyahu
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OMEUyaGdEHA.212@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could someone tell me how can be populated DropdownList from Data Base. I
> use ASP.NET/C#/MS SQL SERVER.
> Thanks!
> Viktor
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.
>
Thanks for the reply!
Could you add the other code?
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
DropDownList2.DataMember = "Table";
DataBind (); // or DropDownList2.DataBind ();
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%23QdEA%23HdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> Thanks for the reply!
> Could you add the other code?
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
>
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
>
Hi, Thanks again for the reply! I wrote that but it doesn't work. Could you
check for an error?
Thanks
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
DropDownList2.DataMember = "Table";
DropDownList2.DataBind () ;
}
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
see inline
"Viktor Popov" <viketo@.yahoo.com> wrote in message news:O5PJdnIdEHA.3616@.TK2MSFTNGP10.phx.g
bl...
> Hi, Thanks again for the reply! I wrote that but it doesn't work. Could yo
u
> check for an error?
> Thanks
> private void Page_Load(object sender, System.EventArgs e)
> {
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataBind () ;
>
add the code (with the correct values):
DropDownList2.DataTextField = "<name of column for visible text>";
DropDownList2.DataValueField = "<name of column for internal value>";
> }
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
I tryed to do that:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
conn.Open();
da.SelectCommand.ExecuteReader();
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
DropDownList2.DataMember = "Table";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataBind () ;]
}
but it doesn't work.
What could I do?
Thanks!
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
what's the error?
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
> I tryed to do that:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer
",
> conn);
> conn.Open();
> da.SelectCommand.ExecuteReader();
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataTextField = "TypeOffer";
> DropDownList2.DataValueField = "OfferID";
> DropDownList2.DataBind () ;]
> }
> but it doesn't work.
> What could I do?
> Thanks!
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
There is no error. When I start the application the DropDownList is empty.
There are no values, no items. My table is full with data
TypeOffer
--
OfferID TypeOffer
1 rent
2 sell
3 change
Do you know what's wrong?
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> what's the error?
> "Viktor Popov" <viketo@.yahoo.com> wrote in message
> news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
blek.TypeOffer
> ",
>
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
Can set a breakpoint after the line with da.Fill (ds,"Table"); and check if
the dataset actually gets any data?
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%231PE14JdEHA.2544@.TK2MSFTNGP10.phx.gbl...
> There is no error. When I start the application the DropDownList is empty.
> There are no values, no items. My table is full with data
> TypeOffer
> --
> OfferID TypeOffer
> 1 rent
> 2 sell
> 3 change
> Do you know what's wrong?
> "Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
> news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> blek.TypeOffer
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment