//Create Procedure.
create proc [dbo].[sp_BindJobType]
as
select JobId,JobType from tblJobType
//Code to Fill Drop Down
public void MFill_DropJobcategory()
{
try
{
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("sp_BindJobType",(SqlConnection)Ncconnection.cconnection.MConnection());
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
ddlJobCategoty.DataValueField = "JobId";
ddlJobCategoty.DataTextField = "JobType";
ddlJobCategoty.DataSource = ds.Tables[0];
ddlJobCategoty.DataBind();
if (ds.Tables[0].Rows.Count > 0)
{
ddlJobCategoty.Items.Insert(0, "----Select----");
}
else
{
ddlJobCategoty.Items.Insert(0, "No Job Type");
}
}
catch (Exception ex) { throw new Exception(ex.Message); }
}
No comments:
Post a Comment