protected void TextBox2_TextChanged(object sender, EventArgs e) { foreach (GridViewRow i in GridView1.Rows) { CheckBox chkUpdate = (CheckBox)i.Cells[0].FindControl("CheckBox1"); if (chkUpdate != null) { if (chkUpdate.Checked == true) { Label lab = (Label)i.FindControl("Label1"); TextBox txt = (TextBox)i.FindControl("TextBox2"); PlaceHolder ph = (PlaceHolder)i.FindControl("PlaceHolder1"); if (txt.Text != "") { for (int j = 0; j < Convert.ToInt16(txt.Text); j++) { Label la1 = new Label(); la1.Text = lab.Text + (j + 1).ToString(); // la1.ID = "abc" + j; using (SqlCommand comm = new SqlCommand("select [Serial_Number_Required] from Products where Product=@Product ", con)) { con.Open(); //string Role = (string)(Session["Role"]); // 2. define parameters used in command object SqlParameter para = null; para = new SqlParameter(); para.ParameterName = "@Product"; para.Value = lab.Text; comm.Parameters.Add(para); //Pass @Pages parameter SqlDataReader reade = comm.ExecuteReader(); while (reade.Read()) { Session["Serial_Number_Required"] = Convert.ToString(reade["Serial_Number_Required"]); } con.Close(); //Button Add = (Button)PreviousPage.FindControl("Button2"); if (Session["Serial_Number_Required"].ToString() == "Y") { ph.Controls.Add(la1); ph.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + j + "'type='Text' />")); ph.Controls.Add(new LiteralControl("<br/>")); } } } } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)