I've tried a few different ways to count the rows in my data table. If the count equals 0 i have a custom error message displayed but the issue I am running into is use of unassigned local variable. Here is my code
I'm trying to use dt.count == 0 but says my dt variable is unassigned
Thanks to all that help out
protected void btnGo_Click(object sender, EventArgs e)
{
//dal.Analytic.AdHoc.Snapshot_OccDataTable dt;
dal.Analytic.AdHoc.adhoc_OccWagesDataTable dt;
//retrieves year and stores in currYear variable
Int16 currYear = (Int16)Cea.Config.ConfigStore.GetConfigInt("Date_OccMatrix");
//user selects years 1-10 subtract that to get historic year
if (Convert.ToInt16(txtYear.Text) > 10)
{
Alert("Year can not be more than 10");
return;
}
else if (dt.Count == 0)
{
dNoDta.Visible = true;
}
else
{
//stores current year and year2 / yrs constant to pass to query
Params["year"] = currYear;
Params["year2"] = currYear - Convert.ToInt16(txtYear.Text);
Params["yrs"] = Convert.ToInt16(txtYear.Text);
Params["year3"] = Params["year2"];
}

New Topic/Question
Reply



MultiQuote





|