Looping through Nested for loops

Posted by Self-Innovator under ASP.NET on 1/11/2013 | Points: 10 | Views : 858 | Status : [Member] | Replies : 0
Hi i have an scenario where i am using multiple for loops while inserting an values..Find my below code where i need to insert an Qid as one of the paraemeter among the others..

protected void Button1_Click(object sender, EventArgs e)
{
string s = "";

string str = string.Empty;
int id = Convert.ToInt32(Session["id"]);
int id1 = Convert.ToInt32(Request.QueryString["id"]);
foreach (RepeaterItem item in DataList1.Items)
{
TextBox txt = (TextBox)item.FindControl("TextBox1");
string ss = txt.Text;
if (String.IsNullOrEmpty(ss))
{
s = "empty field";
}
else
{

s = txt.Text;
jaya j = new jaya();
DataTable dt2 = j.fillquestionuser(id1);
if (dt2.Rows.Count > 0)
{
foreach (DataRow dr in dt2.Rows)
{
Qid = Convert.ToInt32(dt2.Rows[0]["id"].ToString());
}
}
}
einstein en = new einstein();
en.submitanswer(id, id1, s, Qid);
//Qid = Convert.ToInt32(str);
MessageBox msg = new MessageBox();
msg.Show("Assignment answer submitted successfully");
}
}

if my dt2 consists of column id as 27 and 28 two rows,while inserting it inserts only 27 2 times in my table instead off 27 and 28 individually...pls find any soolution

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

(No response found.)

Login to post response