Topic: asp.net homework help
I'm working on a homework assignment for one of my classes and having a problem getting my drop down list working they way I need it to.
So what I need to do is choose one thing on a list and when the user clicks submit, a panel will appear with the corresponding text and images.
I made it work with radio buttons, but when I went back to check the assignment requirements, the instructor was a drop down list
.
This is the code for the radio button:
if (rdoCapricorn.Checked)
{
pnlRead.Visible = true;
pnlHoroscopes.Visible = true;
lblSign.Text = "Capricorn";
imgHoroscope.ImageUrl = "~/signs/capricorn.png";
lblHoroscope.Text = "blah blah blah";
}So the problem I am having is doing the same thing with a drop down list.
I tried using the following lines for the if statement:
if (ddlZodiac.SelectedItem = "Capricorn")if (ddlZodiac.SelectedIndex = 0)if (ddlZodiac.DataValueField = "Capricorn")if (ddlZodiac.DataTextFormatString = "Capricorn")and I getting an error "cannot implicitly convert type string (or int) to bool". I even tried the .ToString at the end of SelectedItem but I get another error which says, "cannot assign to ToString because it is a 'method group'". I don't fully understand the errors which I think is why I'm having a problem.
There has to be simple solution to this that I am completely missing. I don't think our instructor covered. I'm not sure if this makes a difference, but the drop down list has an SqlDataSource called "theZodiac".
below is the code to display the drop down list and code for the database:
<asp:DropDownList ID="ddlZodiac" runat="server"
DataSourceID="theZodiac"
DataTextField="Sign" DataValueField="Sign">
</asp:DropDownList>
<asp:SqlDataSource ID="theZodiac" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Sign] FROM [zodiacSign]">
</asp:SqlDataSource>I'm sorry if this seems like a lot. I'm very new to ASP.Net, so I want to know how to make it work and why the methods I was trying above did not so I know for future reference.
Thanks in advance to anyone who replies! ![]()

