<asp:ListBox ID="ListBox1" runat="server" Height="202px" Width="262px" style="margin-left: 247px; margin-top: 68px" onselectedindexchanged="ListBox2" AutoPostBack="true" EnableViewState="True"> </asp:ListBox>
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { getdata(); } } public void getdata() { string user = Session["name"].ToString(); SqlConnection cnn = new SqlConnection("Data Source=HAMEED_KHAN\\SQLEXPRESS;Initial Catalog=db_compiler;Integrated Security=True"); SqlCommand cmd2 = new SqlCommand("SELECT User_ID from tbl_user WHERE User_Name='" + user + "'", cnn); cnn.Open(); string id = cmd2.ExecuteScalar().ToString(); int ID = Int32.Parse(id); SqlCommand cmd = new SqlCommand("USE db_compiler SELECT Database_Name FROM Create_db WHERE User_ID='" + ID + "'", cnn); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); da.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { string value = row["Database_Name"] + ""; ListBox1.Items.Add(value); } } } public void ListBox2(object sender, EventArgs e) { Session["value"] = ListBox1.SelectedValue; Response.Redirect("CreateTable.aspx"); } }
AutoEventWireup="true"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)