my code is
DataSet sds = new DataSet();
string vew = "select Id,Date,Name,Status,Section,Intime from aten where Id='" + TextBox1.Text + "'";
sds = mvl.GETDS(vew);
GridView1.DataSource = sds;
GridView1.DataBind();
int count = 0;
foreach (GridViewRow row in this.GridView1.Rows)
{
if (row.Cells[3].Text == "Present")
{
count++;
}
}
this.lblStatusCount.Text = count.ToString();
lblStatusCount.ForeColor = System.Drawing.Color.LightPink;
cn = new SqlConnection(s);
cn.Open();
DataSet ds = new DataSet();
string qry = "select Name,Section,present from presentdays where id='" + TextBox1.Text;
qry += "'";
cd = new SqlCommand(qry, cn);
cd.ExecuteNonQuery();
// ds = mvl.GETDS(qry);
foreach (DataRow dr in ds.Tables[0].Rows)
{
TextBox2.Text = dr["present"].ToString();
TextBox12.Text = dr["Name"].ToString();
TextBox13.Text = dr["Section"].ToString();
}
// cd = new SqlCommand(qry, cn);
// cd.ExecuteNonQuery();
cn.Close();
my errror is
Server Error in '/bramandam site' Application.
Cannot find table 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Cannot find table 0.
Source Error:
Line 110: cd.ExecuteNonQuery();
Line 111: // ds = mvl.GETDS(qry);
Line 112: foreach (DataRow dr in ds.Tables[0].Rows)
Line 113: {
Line 114: TextBox2.Text = dr["present"].ToString();
Source File: d:\bramandam site\Salarycalculation.aspx.cs Line: 112
Stack Trace:
[IndexOutOfRangeException: Cannot find table 0.]
System.Data.DataTableCollection.get_Item(Int32 index) +92
Salarycalculation.TextBox1_TextChanged(Object sender, EventArgs e) in d:\bramandam site\Salarycalculation.aspx.cs:112
System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e) +8755606
System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent() +55
System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +10
System.Web.UI.Page.RaiseChangedEvents() +165
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485
Version Information: Microsoft .NET Framework Version:2.0.50727.4984; ASP.NET Version:2.0.50727.4971