473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

coding for dropdownlist

1
hi im new to c# and .net2.0 can anybody plz help ...... i have all the details of empid in dropdown listbox and if i click the empid the date related to that id shoul de displayed......... i have attached the code...plz say me the corrections.....


Expand|Select|Wrap|Line Numbers
  1.  protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         // CODE FOR GETTING THE DATA FROM SQLTABEL
  5.         int employeeid = Convert.ToInt16(DropDownList1.SelectedIndex);
  6.         SqlConnection con = new SqlConnection("Data Source=MS1;Initial Catalog=MSRegSys;uid=sa;Password=ms123");
  7.         con.Open();
  8.         SqlDataAdapter da = new SqlDataAdapter("select EmpID,EmpCode,lo.LocationName,dp.DepName from usr_tblMs_Employee em INNER JOIN usr_tblMs_Department dp ON dp.DeptID=em.DeptID INNER JOIN usr_tblMs_Location lo ON lo.LocationID=dp.LocationID where em.EmpID=employeeid ", con);
  9.         DataSet ds = new DataSet();
  10.         DataTable dt = new DataTable();
  11.         dt=ds.Tables["e"];
  12.         DataRow dr = dt.Rows[0];
  13.         DropDownList1.Text = dr[0].ToString();
  14.         txtempcode.Text = dr[1].ToString();
  15.         txtdept.Text = dr[2].ToString();
  16.         txtlocation.Text = dr[3].ToString();
  17.     }
Mar 19 '07 #1
2 1050
kenobewan
4,871 Expert 4TB
How should the date be displayed? Please explain your requirements clearly and post any errors. Thanks.
Mar 19 '07 #2
hi,

one thing is not clear here..
u cant ve all the details of the employee in dropdownlist.
u can ve all ids in ddlist.
if u ve so.. u ve toi write a code inside dropdownlist_chage()
here it goes..

sqldataadapter da = new sqldataadapter("select date from table where eid= ' " + ddlist.selecteditem.text.trim + " ' ",con);

dataset ds= new dataset();
da.fill(ds,"e")
u can display the date ... label.text= ds.tables["e"].rows[0][0];
u ll get the solution..
try this out
Mar 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
8
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the...
2
by: Shiju Poyilil | last post by:
Hello, I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.