display grid based on combobox values
hi friends,i am developing a windows application,in that i have a combobox in one form when i select a value from combo box a grid should appear on the next form with details related to the combo box on the previous form.....any one help me...i am new to c#
Kirtan PatelPosted Jan 3, 2010, 2:11 AM
---------------
protected void Button1_Click(object sender, EventArgs e)
{
string ComboValue = DropDownList1.SelectedValue.ToString();
Response.Redirect("Page2.aspx?selected=" + ComboValue);
}
Page 2 Code
--------------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Rettive the Value From Query String
string selectedvalue = Request.QueryString[0].ToString();
if (String.IsNullOrEmpty(selectedvalue) == false)
{
SqlConnection con = new SqlConnection("your Connection String");
con.Open();
SqlCommand comm = new SqlCommand("select * from Tablename where Columname='" + selectedvalue + "'", con);
GridView1.DataSource = comm.ExecuteReader();
DataBind();
}
}
}
Hiren SoniPosted Jan 3, 2010, 4:28 AM