J
JB
Hello
I have a dropdownlist that I load from a datasource. The problem is 2
fold. When the page loads the dropdownlist default should be blank. Only
when the user clicks the carat on the side of the dropdownlist, then all of
the selections
should show and then they can select one of those choices from the list.
Instead:
1-When the page loads the dropdownlist shows the first choice in the list
in the dropdownlist box.
The other problem is that not all of the choice are showing in the
dropdownlist box. The datasource is the results of a query that has 5 rows
but:
2-The dropdownlist only shows 4 of the 5 rows that the query returned to
the datasource.
So My questions are:
1-How do I make the dropdownlist default value not show any of the choices
(blank) until the user clicks the carat on the side of the dropdownlist to
making
it reveal all of the choices in the dropdownlist then let them choose one?
2-How do I make all of the 5 rows in the datasource ( query result) show in
the
dropdownlist instead of just 4 of the 5 rows?
a)Below is how the dropdownlist is declared in the aspx page:
<td><aspropDownList ID="ddlCity" Width="150px" height="28px"
font-size="15px" runat="server">
b)Below is how the dropdownlist is declared in the codebehind:
SqlConnection ctyConn = new SqlConnection(ConnStr);
string ctySql = @"select Description from tblCity where ID =
'1' ot 'ID' = '2' ";
SqlCommand ctyComm = new SqlCommand(ctySql, ctyConn);
SqlDataReader reader;
ctyConn.Open();
reader = ctyComm.ExecuteReader();
while (reader.Read())
{
ddlCity.DataSource = reader;
ddlCity.DataValueField = "Description";
ddlCity.DataBind();
}
I have a dropdownlist that I load from a datasource. The problem is 2
fold. When the page loads the dropdownlist default should be blank. Only
when the user clicks the carat on the side of the dropdownlist, then all of
the selections
should show and then they can select one of those choices from the list.
Instead:
1-When the page loads the dropdownlist shows the first choice in the list
in the dropdownlist box.
The other problem is that not all of the choice are showing in the
dropdownlist box. The datasource is the results of a query that has 5 rows
but:
2-The dropdownlist only shows 4 of the 5 rows that the query returned to
the datasource.
So My questions are:
1-How do I make the dropdownlist default value not show any of the choices
(blank) until the user clicks the carat on the side of the dropdownlist to
making
it reveal all of the choices in the dropdownlist then let them choose one?
2-How do I make all of the 5 rows in the datasource ( query result) show in
the
dropdownlist instead of just 4 of the 5 rows?
a)Below is how the dropdownlist is declared in the aspx page:
<td><aspropDownList ID="ddlCity" Width="150px" height="28px"
font-size="15px" runat="server">
b)Below is how the dropdownlist is declared in the codebehind:
SqlConnection ctyConn = new SqlConnection(ConnStr);
string ctySql = @"select Description from tblCity where ID =
'1' ot 'ID' = '2' ";
SqlCommand ctyComm = new SqlCommand(ctySql, ctyConn);
SqlDataReader reader;
ctyConn.Open();
reader = ctyComm.ExecuteReader();
while (reader.Read())
{
ddlCity.DataSource = reader;
ddlCity.DataValueField = "Description";
ddlCity.DataBind();
}