I have a method I call and after the method is called I need to see if it returns no results or results. If it returns results a certain panel is displayed and if no results a certain panel is displayed.
This is my method:
public DataView RedeemCoupon()
{
string connStr = ConfigurationManager.ConnectionStrings["SiteSqlServer"]
.ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("CPC_GetCoupons", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@CouponCode", txtCouponCode.Text));
SqlDataAdapter dap = new System.Data.SqlClient.SqlDataAdapter(cmd);
DataSet ds = new DataSet();
// open conn
if (conn.State == ConnectionState.Closed)
conn.Open();
// fill
dap.Fill(ds);
// close the conn
if (conn.State == ConnectionState.Open)
conn.Close();
return ds.Tables[0].DefaultView;
}
Any ideas?
Thanks!
You can check the
.Table.Rowsproperty ofDefaultView: