0
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.

4

1 回答 1

1

试试看:

int countryid = int.Parse(ddlcountry.SelectedValue);
于 2012-11-21T12:23:50.333 回答