Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I am very new bie to .net .
My scenario is i have a drop down box in page and have Employee ID's inside it.I have a gridview below the dropdown list which is already having data binded from database. what i need is when i select employee ID in dropdown , data related to that particular EMP ID should be shown in gridview .How to do this please help me out thanks in advance.
Posted 25-Apr-13 11:57am
Edited 25-Apr-13 12:06pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Write code in SelectedIndexChanged event of DropDownList:
protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["leave"].ConnectionString;
conn.Open();
SqlCommand cmd = new SqlCommand("select * from emp_details where Emp_id='" + DropDownList.SelectedValue + "'", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
  Permalink  
Comments
Rohan Leuva at 26-Apr-13 0:04am
   
You can accept and vote the answer if it helps you.
vinodk11226 at 26-Apr-13 11:30am
   
It helped me but i am using stored procedure to modify the grid to show the result when a value is selected in dropdown. I am using function to call the sql query in different class now i need to call that function in my current code in SelectedIndexChanged Event of dropdownlist to happen this .Any suggestions how to do that??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 295
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100