Hi..
I'm using Asp.Net with C#....
I'm having One Dropdownlist control(Users_Details_DDL) in Default.aspx Page...
i'm having one Stored Procedure (Get_User_Email) which will display the Data from Database into Dropdownlist control..
Now I'm populating this Dropdownlist control with Stored Procedure in Default.aspx Page... It is working Fine..
This is the way How i'm Populating the Dropdownlist Control in Default.aspx Page..
---------------------------------------------------------------------------------------------------------------------
Page_Load event(----------------)
{
Connection.Open();
if (!IsPostBack)
{
try
{
SqlCommand cmd = new SqlCommand("Get_User_Email", Connection);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader sqlReader = cmd.ExecuteReader();
if (sqlReader.HasRows)
{
Users_Details_DDL.DataSource = sqlReader;
Users_Details_DDL.DataTextField = "User_Email";
Users_Details_DDL.DataValueField = "User_ID";
Users_Details_DDL.DataBind();
sqlReader.Close();
}
}
catch (SqlException ex)
{
ErrorLabel.Text = ex.Message;
ErrorLabel.Visible = true;
}
finally
{
// Close the database connection
//dbHelper.closeDatabaseConnection(dbConn);
}
}
---------------------------------------------------------------------------------------------------------------------
Now i want to do the Same Operation by using Class file (Class1.cs)..
ie I want to Populate the Dropdownlist control with Stored Procedure from Class File(Class1.cs) instead of from Default.aspx Page in C#..
(Here i'm not using any Datasets)
How to do this... Please give me the Code....
Thank You...