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
    Likes Received:
    0
    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. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
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:
    3,013
    Malke
    Sep 23, 2005
  2. dbmasterguru@yahoo.de
    Replies:
    1
    Views:
    926
    dbmasterguru@yahoo.de
    May 9, 2005
  3. Brown Dwarf

    Bluetooth bind() fails with WSANETDOWN

    Brown Dwarf, Apr 10, 2006, in forum: Wireless Networking
    Replies:
    0
    Views:
    1,319
    Brown Dwarf
    Apr 10, 2006
  4. Edward Holub
    Replies:
    1
    Views:
    569
    Dennis M
    Aug 26, 2004
  5. Kompu Kid

    How to "bind" two files

    Kompu Kid, Sep 5, 2007, in forum: Computer Support
    Replies:
    10
    Views:
    918
    Mark S.
    Sep 6, 2007
  6. gnewsgroup@gmail.com

    How do we bind our IP to a godaddy domain?

    gnewsgroup@gmail.com, Sep 11, 2007, in forum: Cisco
    Replies:
    11
    Views:
    5,091
    hostmaama
    Jul 18, 2013
  7. naza

    Bind programs to Network adapter

    naza, Feb 2, 2008, in forum: Computer Support
    Replies:
    1
    Views:
    963
  8. kasbekar.ajay

    Asp.Net Bind javascript to textbox

    kasbekar.ajay, Apr 22, 2010, in forum: Software
    Replies:
    0
    Views:
    3,620
    kasbekar.ajay
    Apr 22, 2010
Loading...