I have got a grid view in that I have two label and then a checkbox.
In presentation layer ie .cs i have the coding like
in Data Access Layer I have
in Business Access layer
the same story
now the problem that arise is that
1. condition for the checkbox is not done,the values is always "absent " even if we check the checkbox
2. the values gets inserted only for the first time and in the second time and third time it shows an error as object reference not set to as instance.
what has to be done?
Thanks in advance
Raghul
In presentation layer ie .cs i have the coding like
Code:
foreach(GridViewRow row in GridView1.Rows)
{
if(row.RowType == DataControlRowType.DataRow)
{
empid = int.parse(((Label)row.FindControl("Lbl1")).Text);
name = (((Label)row.FindControl("Lbl2")).Text);
bool ischecked = (((CheckBox)row.FindControl("CheckBox")).Checked);
if(ischecked)
{
status = "Present"
}
else
{
status = "Absent"
}
}
}
Code:
try
{
connection.Open();
cmd = new SqlCommand("sp for insert",connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@empid",empid);
cmd.Parameters.AddWithValue("@name",name);
cmd.Parameters.AddWithValue("@status",status);
}
catch
{
throw;
}
the same story
now the problem that arise is that
1. condition for the checkbox is not done,the values is always "absent " even if we check the checkbox
2. the values gets inserted only for the first time and in the second time and third time it shows an error as object reference not set to as instance.
what has to be done?
Thanks in advance
Raghul
Comment