4
Answers

How can i am Add sqlData Base values in gridview dropdown list ....

Sachin Mitna

Sachin Mitna

4y
531
1
if (!IsPostBack)
{
SetIntailRow();
// SetGrid();
this.BindGrid();
}
SqlConnection con = new SqlConnection(@"Data Source=AQSASHAIKH\SQLEXPRESS;Initial Catalog=Client;Integrated Security=True");
string com = "Select * From [dbo].[client]";
SqlDataAdapter da = new SqlDataAdapter(com, con);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataBind();
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "id";
DropDownList1.DataBind();
SqlConnection Conn = new SqlConnection(@"Data Source=AQSASHAIKH\SQLEXPRESS;Initial Catalog=Client;Integrated Security=True");
SqlCommand Comm1 = new SqlCommand(com, Conn);
Comm1.Connection = Conn;
Comm1.CommandText = "SELECT COUNT(*) FROM client";
Conn.Open();
TxtBox1.Text = Comm1.ExecuteScalar().ToString();
TxtBox2.Text = Comm1.ExecuteScalar().ToString();
Conn.Close();
}
Answers (4)