fill dropdown list by querystring
I Had Drop down list and I want to fill it with data from database through stored procedure and it had it,s value when specific query string I had two query string.
as
private void LoadWithCategory() { if (Request.QueryString["Category_Id"] != null) { using (SqlConnection Con = Connection.GetConnection()) {
SqlCommand Com = new SqlCommand("GetProducFamilyTP", Con);
Com.CommandType = CommandType.StoredProcedure;
Com.Parameters.Add(Parameter.NewInt("@Category_Id",开发者_StackOverflow Request.QueryString["Category_Id"]));
SqlDataReader DR = Com.ExecuteReader();
if (DR.Read())
{
DDLProductFamily.DataSource = DR;
DDLProductFamily.DataTextField = DR["Name"].ToString();
DDLProductFamily.DataValueField = DR["ProductCategory_Id"].ToString();
DDLProductFamily.DataBind();
}
DR.Close();
}
}
}
ALTER Proc GetProducFamilyTP ( @Category_Id Int ) AS Select Distinct Categories.Category_Id ,ProductCategory.Name , ProductCategory.ProductCategory_Id From Category_ProductCategory
Inner Join Categories On Category_ProductCategory.Category_Id=Categories.Category_Id Inner Join ProductCategory On Category_ProductCategory.ProductCategory_Id=ProductCategory.ProductCategory_Id Where Categories.Category_Id =@Category_Id
but this error occurred
DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name '4Door'.
The error was in ddl list when I removed it it worked well it had value=0
精彩评论