pblm when bind data to dropdoen with datareader

Discussion in 'MCSE' started by srilakshmi, Jun 1, 2011.

  1. srilakshmi

    srilakshmi

    Joined:
    Jun 1, 2011
    Messages:
    1
    hi ,

    when iam binding data to dropdown with datareader i use this code it is working properly
    while (dr.Read())
    {


    DropDownList1.DataSource = dr;

    DropDownList1.DataTextField = "countryname";
    DropDownList1.DataValueField = "countryname";

    DropDownList1.DataBind();


    }


    but i use like this iam getting error
    while (dr.Read())
    {


    DropDownList1.DataSource = dr;

    DropDownList1.DataTextField = dr[1].ToString();
    DropDownList1.DataValueField = dr[1].ToString();

    DropDownList1.DataBind();


    }

    error is :: DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'INDIA'.
    i am not understanding why that error comes.
    if any one knows can u tell me pls
    ---thank you
     
    srilakshmi, Jun 1, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9zbWFuIENvbXB1dGluZw==?=

    Cannot bind to tcp/ip

    =?Utf-8?B?Um9zbWFuIENvbXB1dGluZw==?=, Sep 23, 2005, in forum: Wireless Networking
    Replies:
    1
    Views:
    2,668
    Malke
    Sep 23, 2005
  2. dbmasterguru@yahoo.de
    Replies:
    1
    Views:
    717
    dbmasterguru@yahoo.de
    May 9, 2005
  3. jacksu
    Replies:
    0
    Views:
    1,319
    jacksu
    Mar 2, 2004
  4. Ant

    70-219 BIND Question?

    Ant, Jun 16, 2004, in forum: MCSE
    Replies:
    3
    Views:
    1,539
    Kurt Hudson [MVP DS]
    Jun 17, 2004
  5. Brown Dwarf

    Bluetooth bind() fails with WSANETDOWN

    Brown Dwarf, Apr 10, 2006, in forum: Wireless Networking
    Replies:
    0
    Views:
    1,030
    Brown Dwarf
    Apr 10, 2006
Loading...

Share This Page