2013-10-04 57 views
1

如何從中繼器控制實際值到列表框控件,爲此我寫下面的代碼,但我得到的值system.data.datarowview ...system.data.datarowview在列表框c#asp.net

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(); 
} 

回答

0

你必須指定DataTextFieldDataValueFieldDropDownList

ddlSelectCountryName.DataSource = objDataTable;   
ddlSelectCountryName.DataTextField = "Country_Name"; //here 
ddlSelectCountryName.DataValueField = "Country_Name"; 
ddlSelectCountryName.DataBind();