1

如何从中继器控件获取实际值到列表框控件,为此我编写了以下代码,但我得到了值 system.data.datarowview ...

protected void BindContriesDropDownList()
{
    SqlCommand objSqlCommand = null;
    strSQL = @"SELECT Country_Name FROM Country_Master";
    objSqlCommand = new SqlCommand(strSQL, objSqlDbComm.SqlConnectionObject);
    objSqlCommand.Parameters.AddWithValue("@paramCountry_Name", ddlSelectCountryName.Text);
    DataTable objDataTable = objSqlDbComm.ExecuteDataTable(objSqlCommand);
    ddlSelectCountryName.DataSource = objDataTable;        
    ddlSelectCountryName.DataBind();
}
4

1 回答 1

0

您必须指定DataTextFieldDataValueField为您的DropDownList

ddlSelectCountryName.DataSource = objDataTable;        
ddlSelectCountryName.DataTextField = "Country_Name"; //here
ddlSelectCountryName.DataValueField = "Country_Name";
ddlSelectCountryName.DataBind();
于 2013-10-04T13:43:40.463 回答