c# - Unable to bind data to DropDownList -
i binding xml values dropdownlist. below code:
protected void loaddropdown() { dataset ds = new dataset(); ds.readxml (server.mappath(@"xmlfile1.xml")); dropdownlist1.datatextfield = "country_id"; dropdownlist1.datasource = ds; dropdownlist1.databind(); dropdownlist1.items.insert(0,new listitem(" select ","0")); } i want country names in dropdownlist, getting id values 0,1,2,3. doing wrong?
try specifying else datatextfield:
dropdownlist1.datatextfield = "country_name"; //this value depends on xml structure is. dropdownlist1.datavaluefield = "country_id";
Comments
Post a Comment