hi guys, Following is my stored procedure.
ALTER PROCEDURE SP_GetModels
(
@CategoryID bigint
)
AS
BEGIN
Select ModelID,ModelName From Model where CategoryID=@CategoryID
END
and i am calling stored procedure in code behind as
public SqlConnection conn;
public SqlDataReader GetModels()
{
DataTable dt = new DataTable();
public void DbConnection()
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SampleCs"].ConnectionString);
conn.Open();
}
DbConnection();
SqlCommand cmd = new SqlCommand("SP_GetModels", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CategoryID", SqlDbType.BigInt, 10).Value = CategoryID;
// SqlDataAdapter madap = new SqlDataAdapter(cmd, conn);
SqlDataReader dreader= cmd.ExecuteReader();
//madap.Fill(dt);
return dreader;
}
I have a dropdownlist to which i have to bind datareader object which contain modelname. how can i set datasource to dropdownlist as datareader