using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class assigned : System.Web.UI.Page
{
DropDownList d;
DropDownList dr;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
try
{
for (int i = 0; i < a; i++)
{
d = new DropDownList();
d.ID = "Text" + i;
LiteralControl l1 = new LiteralControl("<br></br>");
SqlConnection con1 = new SqlConnection("Data Source=ABC-0D30299B90A;Initial Catalog=JAPIT;Integrated Security=True");
con1.Open();
d.Items.Add("anant");
d.Items.Add("Gautum");
//Session[""+i]=i;
//Session["current"] = i;
//Session["Product" + i] = d;
//Session["id" + i] = d.ID;
//Session["seleted" + i] = d.SelectedValue.ToString();
//d.SelectedIndexChanged += new EventHandler(d_SelectedIndexChanged);
//string st = "select doe_name from Doe_detail ";
//SqlCommand cmd = new SqlCommand(st, con1);
//SqlDataReader dr = cmd.ExecuteReader();
//while (dr.Read())
//{
// d.Items.Add(dr.GetString(0).ToString());
//}
Panel3.Controls.Add(d);
Panel3.Controls.Add(l1);
con1.Close();
}
}
catch (Exception e1)
{
Label4.Text = "" + e1.Message.ToString();
}
}
void d_SelectedIndexChanged(object sender, EventArgs e)
{
int i;
i = (int)Session["current"];
dr = (DropDownList)Session["Product" + i];
dr.ID = (String)Session["id" + i];
Session["seleted" + i] = d.SelectedValue.ToString(); ;
}
protected void Button2_Click(object sender, EventArgs e)
{
//try
//{
int a = Convert.ToInt32(TextBox1.Text);
string value = "";
for (int i = 0; i < a; i++)
{
dr = new DropDownList();
//value = d.SelectedValue.ToString();
//DropDownList d = new DropDownList();
//dr = new DropDownList();
//dr= (DropDownList)Session["Productid" + i];
//dr.ID = "Text" + i;
//dr = (DropDownList)Session["Product" + i];
//dr.ID = (String)Session["id" + i];
//DropDownList d = (DropDownList)this.Page.FindControl("Text" + i);
DropDownList d = (DropDownList)Panel3.FindControl("Text" + i);
value = d.SelectedValue.ToString();
//value = dr.SelectedValue.ToString(); ;
//value = dr.SelectedValue();
SqlConnection con = new SqlConnection("Data Source=ABC-0D30299B90A;Initial Catalog=JAPIT;Integrated Security=True");
// SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["JAPITConnectionString"].ToString());
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into niitstud values('" + value + "')", con);
cmd1.ExecuteNonQuery();
con.Close();
}
//}
//catch (Exception e2)
//{
// Label4.Text = "" + e2.Message.ToString();
//}
}
}
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class assigned : System.Web.UI.Page
{
DropDownList d;
DropDownList dr;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(TextBox1.Text);
try
{
for (int i = 0; i < a; i++)
{
d = new DropDownList();
d.ID = "Text" + i;
LiteralControl l1 = new LiteralControl("<br></br>");
SqlConnection con1 = new SqlConnection("Data Source=ABC-0D30299B90A;Initial Catalog=JAPIT;Integrated Security=True");
con1.Open();
d.Items.Add("anant");
d.Items.Add("Gautum");
//Session[""+i]=i;
//Session["current"] = i;
//Session["Product" + i] = d;
//Session["id" + i] = d.ID;
//Session["seleted" + i] = d.SelectedValue.ToString();
//d.SelectedIndexChanged += new EventHandler(d_SelectedIndexChanged);
//string st = "select doe_name from Doe_detail ";
//SqlCommand cmd = new SqlCommand(st, con1);
//SqlDataReader dr = cmd.ExecuteReader();
//while (dr.Read())
//{
// d.Items.Add(dr.GetString(0).ToString());
//}
Panel3.Controls.Add(d);
Panel3.Controls.Add(l1);
con1.Close();
}
}
catch (Exception e1)
{
Label4.Text = "" + e1.Message.ToString();
}
}
void d_SelectedIndexChanged(object sender, EventArgs e)
{
int i;
i = (int)Session["current"];
dr = (DropDownList)Session["Product" + i];
dr.ID = (String)Session["id" + i];
Session["seleted" + i] = d.SelectedValue.ToString(); ;
}
protected void Button2_Click(object sender, EventArgs e)
{
//try
//{
int a = Convert.ToInt32(TextBox1.Text);
string value = "";
for (int i = 0; i < a; i++)
{
dr = new DropDownList();
//value = d.SelectedValue.ToString();
//DropDownList d = new DropDownList();
//dr = new DropDownList();
//dr= (DropDownList)Session["Productid" + i];
//dr.ID = "Text" + i;
//dr = (DropDownList)Session["Product" + i];
//dr.ID = (String)Session["id" + i];
//DropDownList d = (DropDownList)this.Page.FindControl("Text" + i);
DropDownList d = (DropDownList)Panel3.FindControl("Text" + i);
value = d.SelectedValue.ToString();
//value = dr.SelectedValue.ToString(); ;
//value = dr.SelectedValue();
SqlConnection con = new SqlConnection("Data Source=ABC-0D30299B90A;Initial Catalog=JAPIT;Integrated Security=True");
// SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["JAPITConnectionString"].ToString());
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into niitstud values('" + value + "')", con);
cmd1.ExecuteNonQuery();
con.Close();
}
//}
//catch (Exception e2)
//{
// Label4.Text = "" + e2.Message.ToString();
//}
}
}