Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
how do i get "id" of selectedvalue in dropdown list which is comming from datatable?
Pawan kumar Shukla
March 27, 2011
SqlCommand sqlcmd = new SqlCommand("select id, p_name from players where id_team = (select team1 from schedule where match_no='" + ddl_matchno.SelectedValue.ToString() + "')", sqlcon);
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
DataTable dtbat = new DataTable();
ddl_bat_team.DataSource = dtbat;
ddl_bat_team.DataTextField = "p_name";
lblp_name.Text = "??????????";
like to get "id" of selected player in ddl_bat_team to lblp_name.Text??
Posted Date: March 27, 2011 Points: 20
you can use such method to assign value to
oda.SelectCommand.CommandType = CommandType.StoredProcedure
dropdown.DataSource = ods
dropdown.DataValueField = "StateProvinceDisplayID"
dropdown.DataTextField = "StateProvinceCombined"
and for getting its value,
use - dropdown.selectedvalue
Please check the following link,
Thanks & Regards
Posted Date: March 28, 2011 Points: 20
Use datatextfield and datavaluefield property of dropdown while binding the combobox.
Then use cmbCombo.selectedvalue property to get the selected value.
To post reply
Related Questions Related Questions
Dropdown list control
Edit dropdown list in gridview
how to insert data into dropdown list in asp
how to Bind Values into to multiple DropDown List
How to get country-State-City information in dropdown list
multi select checkbox list in dropdown
How to Add a List View control in the Web Application
bind xml file data into datatable
Where I can get the list and their solution for errors in C sharp
Latest Forum Questions From The Same Category
Slash(/) in Combobox
attaching the report in the web page
How do i get payment status in redirect page using bitpay?
Login with Facebook and Save details in database
Login with facebook account in my website
How to make a nested datalist control?
What class does Icon derive from?
What are the validation controls?
What''s the difference between an interface and abstract class?
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend