Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4622582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:51:49+00:00 2026-05-22T02:51:49+00:00

I just added a DropDownList to my ASP.NET webpage. Now, when I run, it

  • 0

I just added a DropDownList to my ASP.NET webpage.

Now, when I run, it gives me following error:

error CS0117: ‘System.Web.UI.Control’ does not contain a definition for ‘ItemIndex’

What could be wrong?

Edit: This is the portion I added:

<div id="AddUsers" runat="server" style="border: 1px solid skyblue; background-color: #DDEEFF;" visible="true">
    <table width="100%">
        <tr>
            <td class="style2">
                <b>First Name</b><span style="color: #cc0000">
            *</span></td>
            <td class="style3">
                <b>Middle Name</b> </td>

            <td class="style2">
                <b>Last Name</b><span style="color: #cc0000">
            *</span></td>
            <td style=" width: 100px;" >
                <b>PAN No</b><span style="color: #cc0000">
            *</span></td>
            <td style=" width: 100px;" >
                <b>Financial Year</b></td>
            <td width="13%">
            </td>
        </tr>
        <tr>
            <td class="style2">
                <asp:TextBox ID="txtFirstName_1" runat="server" CssClass="fields" Width="100px" Height="18px" MaxLength="25" />
            </td>
            <td class="style4">
                <asp:TextBox ID="txtMiddleName" runat="server" CssClass="fields" MaxLength="75" Width="100px" Height="18px" />
            </td>
            <td class="style2">&
                <asp:TextBox ID="txtLastName_1" runat="server" CssClass="fields" MaxLength="25" Width="100px" Height="18px" />
            </td>
            <td style="width: 110px;font-weight: bold;color: #000000;">
                <asp:TextBox ID="txtPAN_NumberI_p1" runat="server" style="text-transform: uppercase" CssClass="fields" MaxLength="10"  Width="100px" Height="18px" />
            </td>
            <td style="width: 110px;font-weight: bold;color: #000000;">
                <asp:DropDownList ID="ddlChooseFY" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlChooseFY_SelectedIndexChanged">
                    <asp:ListItem Value="-- SELECT --">-- SELECT --</asp:ListItem>
                    <asp:ListItem Value="2011">2009 - 2010</asp:ListItem>
                    <asp:ListItem Value="2010">2010 - 2011</asp:ListItem>
                </asp:DropDownList>
            </td>
            <td width="13%">
                <asp:Button ID="imgAdd" runat="server" Text="Add User" CssClass="button" Height="22px" onclick="imgAdd_Click" Width="76px" /> 
            </td>
            <td width="10%">
                <input id="Button1" type="button" class="button1" onclick="ClearUser();" style="cursor:pointer" value="Clear" />
            </td>
        </tr>
    </table>
    <br />
    <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOTE</b>: PAN 
    No. once entered cannot be changed. Hence, please ensure that your PAN No is 
    correct.<br />       
</div>

Code:

Session["Year"].ToString() = ddlChooseFY.SelectedItem.Value.ToString();
res = Common.UserAdd(Session["UserName"].ToString(), Session["Year"].ToString(), txtPAN_NumberI_p1.Text.ToUpper());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:51:50+00:00Added an answer on May 22, 2026 at 2:51 am
    Control item = dropDownList1.Items[0];
    item.ItemIndex; // cs0117
    

    but

    ListItem item = dropDownList1.Items[0];
    item.ItemIndex; // ok
    

    what means that you need to clarify the type before use. In most cases cast will help:

    Control item;
    ((ListItem)item).ItemIndex
    

    string year = ddlChooseFY.SelectedItem.Value; // already string, don't call ToString()
    //Session["Year"].ToString() // no!! don't do this, this makes no sense at all
    Session["Year"] = year; // do this instead
    
    string year = (string)Session["Year"]; // cache and cast, if you know the actual type
    // or Session["Year"] as string; if (year != null) ...
    res = Common.UserAdd(year, year, txtPAN_NumberI_p1.Text.ToUpper());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Visual Studio I just added a web service reference to my Asp.net website,
I just added the Ninject.MVC3 nuget package (v2.2.2.0) to my ASP.NET MVC 3 app.
Having just added a new button in my web application, I get an error
I just added this to my web.xml on my JBOSS server. But it had
I just added adds to my app, but the moment i run it i
I've just added yet another 3rd-party component to my .net project that contains a
I can't seem to figure this out. I have an asp DropDownList control. This
I have a user control I'm building (ASP.NET 3.5, using C#). This control is
I just added a namespace to my XML document and now my XSLT stylesheet
I just added an existing solution to TFS source control. This was my first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.