I've got this block of code in C# code-behind that fills a combo box:
ddlRole.Items.Clear();
ddlRole.SelectedValue = null;
DataTable DDLRoles = new DataTable();
using (SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["CLTDPL"].ConnectionString))
{
//SqlDataAdapter adapter = new SqlDataAdapter("Select [Role_ID], [Role] from [MOS_Role] where [Function_ID] = " + FunID + " ORDER BY [Role] ASC", con2);
SqlDataAdapter adapter = new SqlDataAdapter("Select [Role_ID], [Role], [BILLABLE_LBL] from [MOS_Role] where [Function_ID] = @FunID ORDER BY [Role] ASC", con2);
adapter.SelectCommand.Parameters.AddWithValue("@FunID", Convert.ToInt32(ddlFunction.SelectedValue));
adapter.Fill(DDLRoles);
ddlRole.DataSource = DDLRoles;
ddlRole.DataTextField = "Role";
ddlRole.DataValueField = "Role_ID";
ddlRole.DataBind();
}
ddlRole.Items.Insert(0, new ListItem("Select your role", "0"));
Now I'm being asked to change a label based on the field [BILLABLE_LBL]. So, I need to check if that field is NULL or 0, and write an If/Else statement based on that. However, I can't figure out how to get that value.
I mean, I could make a separate call to the data and use a reader, but that can't be the most efficient way.