Click here to Skip to main content
13,046,480 members (72,823 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 10:57am
Updated 25-Apr-13 11:06am

1 solution

Rate this: bad
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;
SqlCommand cmd = new SqlCommand("select * from emp_details where Emp_id='" + DropDownList.SelectedValue + "'", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
GridView1.DataSource = ds;
Rohan Leuva 26-Apr-13 0:04am
You can accept and vote the answer if it helps you.
vinodk11226 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2017
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