You can return a
DataTable
and bind that directly. Let me update your code.
public DataTable GetTimeZones()
{
DataTable dtTimeZones = new DataTable();
SqlCommand cmd = new SqlCommand("sp_EP_GetTimeZones;", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dtTimeZones);
return dtTimeZones;
}
While binding, you can do like...
ddlTimeZones.DataSource = GetTimeZones();
ddlTimeZones.DataTextField = "Zonetime";
ddlTimeZones.DataValueField = "Zonetime";
ddlTimeZones.DataBind();
I have assigned
Zonetime
for to both
Value
and
ID
. If you have any other column value, then just fetch that in procedure and update here.