Reputation: 97
var countries = context.MasterCountries.ToList();
ddlcountry.DataSource = countries;
ddlcountry.DataTextField = "Description";
ddlcountry.DataValueField = "Id";
ddlcountry.DataBind();
<asp:DropDownList runat="server" ID="ddlcountry" CssClass="textbox textbox-reg" />
int countryid = ddlcountry.SelectedIndex;
I am trying to get the id of the company but it's not working.
Upvotes: 0
Views: 67
Reputation: 13296
Try that:
int countryid = int.Parse(ddlcountry.SelectedValue);
Upvotes: 1