[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'FindStringExact'

Posted on 2014-03-17
4
Medium Priority
?
888 Views
Last Modified: 2014-03-17
I am getting the following error:
'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'FindStringExact' and no extension method 'FindStringExact' accepting a first argument of type 'System.Web.UI.WebControls.DropDownList'
could be found.
int intCboIndex = cboServers.FindStringExact(LocalServerName);// error here
Thanks in advance for any help given.
Below is the complete code for clarity.
protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Cursor = Cursors.WaitCursor;
        //get a DataTable of the servers
        DataTable dtList = SMOUtilities.ListAllKnownInstances();
        foreach (DataRow dr in dtList.Rows)
        {
            String ServerName;
            ServerName = dr["Server"].ToString();
            if (!String.IsNullOrEmpty(dr["Instance"].ToString()))
            {
                ServerName += @"\" + dr["Instance"].ToString();
            }
            if (cboServers.Items.IndexOf(ServerName) < 0)// error here
            {
                cboServers.Items.Add(ServerName);
            }
        }
        //  By default select the local server
        Server LocalServer = new Server();
        String LocalServerName = LocalServer.Name;
        if (!String.IsNullOrEmpty(LocalServer.InstanceName))
        {
            LocalServerName += @"\" + LocalServer.InstanceName;
        }
        int intCboIndex = cboServers.FindStringExact(LocalServerName);// error here
        if (intCboIndex >= 0)
        {
            cboServers.SelectedIndex = intCboIndex;
        }
        //Cursor = Cursors.Default;
    }

Open in new window

0
Comment
Question by:homeshopper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 39933990
Basically that means the function does not exist.
You need to use a different function.
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39934006
The Items collection support FindByText and FindByValue methods. But you need to chain a couple of methods to get the index:
int indexCboIndex = cboServers.Items.IndexOf(cboServers.Items.FindByText(LocalServerName));

Open in new window

For info: The FindStringExact method applies to the ComboBox control in WinForms development, it isn't valid for the DropDownList in ASP.Net.
0
 

Author Comment

by:homeshopper
ID: 39934079
Thanks, it now all works.
0
 

Author Closing Comment

by:homeshopper
ID: 39934082
I thought it might be something to do with the conversion of winforms to asp.net
I did not know what other function could used. Thank you for the solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question