C# :: DropDownList Is Not Being Populated
Apr 11, 2014
My query APPEARS to not return any results to populate my dropdown list.
public void getColumnList() {
SqlConnection con;
SqlCommand cmd;
SqlDataReader dataReader;
con = new SqlConnection(ConfigurationManager.AppSettings["ConString"]);
cmd = new SqlCommand();
[code]....
following code successfuly puts my CommandText within the DropDownList. If I copy and paste the CommandText straight into SQL server, it indeed returns the names of the columns.
dataReader.Read();
if (dataReader.HasRows) {
while (dataReader.Read()) {
chkbxlstColumn.Items.Add(cmd.CommandText);
}
}
So if my query is correct enough for SQL Server, why can't C# and ASP.NET recognize the results returned and put it into my control?
FYI I've even tried the blow (initially) and it didn't work either.
chkbxlstColumn.DataSource = dataReader;
chkbxlstColumn.DataValueField = "name";
chkbxlstColumn.DataTextField = "name";
chkbxlstColumn.DataBind();
View 1 Replies
Aug 1, 2012
I have a Dropdownlist with in a gridview, in my grid I have 10 records, my dropdown values are 1,2,3...10. In first record drop down value is 1, second record dropdown value is 2....
1.now I changed the 5 drop down value to 2, then second drop value is changed to 3 and 3 dropdown has been changed to 4, 4th dropdown has been changed to 5
2.I changed the 5th drop down value to 8, then 8th dropdown value is changed to 7, 7th dropdown has been changed to 6, 6th dropdown has been changed to 5
Attached Files PAM.zip (7.0 KB, 87 views)
View 1 Replies
View Related
Nov 26, 2013
Data is not getting updated in dropdownlist using data set:
protected void SpecificationNameDropDownList_SelectedIndexChanged(object sender, EventArgs e) {
if (SpecificationNameDropDownList.SelectedItem.Text != null) {
SpecificationValueLabel.Visible = true;
SpecificationValueDropDownList.Visible = true;
[code].....
View 1 Replies
View Related
Nov 13, 2013
I have created a form (in ASP.NET and C#) which have 5 dropdown
1.3rd dropdown fill on the basis of 1st n 2nd dropdown value
2.5th dropdown fill on the basis of 4th dropdown value
I applied onselectedindexchanged event on 2nd and 4th dropdown and both are autopostback true.All values come according to the requirement.
Problem is when I select a value in 3rd dropdown and it becoming change when I select some value from 4th dropdown.
View 1 Replies
View Related
Apr 3, 2013
I am using MVC3 (C#) and I need to hard code the data in a DropDownList.
View 2 Replies
View Related