rejfields s1 = new rejfields();
if(ddplRS.SelectedValue == "0")
{
lblDataMsg.Text = "Please select Reject Section.";
}
else if (GridView2.Rows.Count.Equals(0))
{
s1.Section = ddplRS.SelectedItem.ToString();
s1.Description = ddplRS0.SelectedItem.ToString();
data.Add(s1);
ViewState["_data"] = data;
GridView2.DataSource = data;
GridView2.DataBind();
lblDataMsg.Text = "";
}
else
{
bool found = false;
for (int i = 0; i < GridView2.Rows.Count; i++)
{
if (GridView2.Rows[i].Cells[0].Text == ddplRS.SelectedItem.Text)
{
lblDataMsg.Text = String.Format("Section {0} already added.", GridView2.Rows[i].Cells[0].Text);
found = true;
}
}
if (!found)
{
s1.Section = ddplRS.SelectedItem.ToString();
s1.Description = ddplRS0.SelectedItem.ToString();
data.Add(s1);
ViewState["_data"] = data;
GridView2.DataSource = data;
GridView2.DataBind();
lblDataMsg.Text = "";
}
}
}