Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (Page.IsPostBack==false)
            {
                Connectionstring.Bldset.Clear();
                Connectionstring.Bldcmd.CommandText ="select stateId from dbo.State;select       CountryId from dbo.Country";
                Connectionstring.BldAdp.SelectCommand = Connectionstring.Bldcmd;
                Connectionstring.BldAdp.Fill(Connectionstring.Bldset);
                DdlStateId.DataSource = Connectionstring.Bldset.Tables[0];
                DdlStateId.DataTextField = "stateId";
                DdlStateId.DataValueField = "StateId";
                DdlStateId.DataBind();
//up to here code working
                DdlCountryID.DataSource = Connectionstring.Bldset.Tables[1];
                DdlCountryID.DataTextField = "CountryId";
                DdlCountryID.DataValueField = "CountryId";
//here i am getting error that 'System.Data.DataRowView' does not contain a property with the name 'CountryId'                 
DdlCountryID.DataBind();

            }
Posted
Updated 10-Aug-13 0:08am
v2

1 solution

On your aspx page where you've declared DdlCountryId, check that BOTH these two keys are like below:
C#
DataTextField="CountryId"
DataValueField="CountryId"

This should fix it. The important thing is to match these two strings to the string here -->
'select CountryId from dbo.Country'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900