Click here to Skip to main content
16,004,778 members
Home / Discussions / C#
   

C#

 
GeneralRe: couldn't remove controls Pin
Lutosław26-Jul-08 12:46
Lutosław26-Jul-08 12:46 
AnswerRe: couldn't remove controls Pin
Luc Pattyn26-Jul-08 10:21
sitebuilderLuc Pattyn26-Jul-08 10:21 
GeneralRe: couldn't remove controls Pin
netJP12L26-Jul-08 10:46
netJP12L26-Jul-08 10:46 
GeneralRe: couldn't remove controls Pin
Mark Salsbery26-Jul-08 10:51
Mark Salsbery26-Jul-08 10:51 
GeneralRe: couldn't remove controls Pin
Luc Pattyn26-Jul-08 10:54
sitebuilderLuc Pattyn26-Jul-08 10:54 
GeneralRe: couldn't remove controls Pin
Luc Pattyn26-Jul-08 12:59
sitebuilderLuc Pattyn26-Jul-08 12:59 
Questiondatagrid column binding Pin
bfis10813726-Jul-08 8:43
bfis10813726-Jul-08 8:43 
QuestionCounting duplicate entries in an ArrayList Pin
Jacob Dixon26-Jul-08 7:21
Jacob Dixon26-Jul-08 7:21 
Is there something that you can use to count duplicate entries in an ArrayList?

I have a table that tells if a person is available and adds it to one arraylist. Then I have another table that contains tickets and who the ticket is assigned to. Now what I want to do is search the tickets for the Assigned field if that person is in the available ArrayList:


<br />
    ArrayList admins = new ArrayList();<br />
    ArrayList available = new ArrayList();<br />
<br />
//This gets the AVAILABLE system administrators listed in the table.<br />
        SqlDataSource sa = new SqlDataSource(ConfigurationManager.ConnectionStrings["HelpDeskConnectionString"].ConnectionString, "SELECT [Admins] FROM [Admin_Table] WHERE ([Area] = 'System Administrator') AND ([Available] = 'True')");<br />
<br />
//This pulls all the tickets from the Tickets table that users have submitted and looks for the <br />
//Assigned field where it equals System Administrator<br />
        SqlDataSource count = new SqlDataSource(ConfigurationManager.ConnectionStrings["HelpDeskConnectionString"].ConnectionString, "SELECT [Assigned] FROM [User_Submit] WHERE ([Type] = 'System Administrator')");<br />
<br />
// Great Gridviews and bind them to the SqlDAtaSource<br />
        GridView gvAvail = new GridView();<br />
        gvAvail.DataSource = sa;<br />
        gvAvail.Visible = false;<br />
        gvAvail.DataBind();<br />
        this.Controls.Add(gvAvail);<br />
<br />
        GridView gvCount = new GridView();<br />
        gvCount.DataSource = count;<br />
        gvCount.Visible = false;<br />
        gvCount.DataBind();<br />
        this.Controls.Add(gvCount);<br />
<br />
// This reads the GridView that contains everyone that is available.<br />
        foreach (GridViewRow row in gvAvail.Rows)<br />
        {<br />
            available.Add(row.Cells[0].Text);<br />
        }<br />
// Now this reads the other GridView and adds the System Administrators name to an ArrayList if<br />
// They are listed as available which is all the names in the first ArrayList (available).<br />
        for (int i = 0; i < gvCount.Rows.Count; i++)<br />
        {<br />
            if (available.Contains(gvCount.Rows[i].Cells[0].Text))<br />
            {<br />
                admins.Add(gvCount.Rows[i].Cells[0].Text);<br />
            }<br />
        }<br />
<br />


Ok so now I have been racking my brain on this.. So as of right now I know who is available and I have the information of how many Tickets each System Administrator has at the current moment (that is the information in the admins ArrayList.

So I will have duplicate names. Lets say Jane Smith and John Doe are listed in the admins ArrayList. Jane Smith is listed 10 times and John Doe is listed 12 times. So the next ticket that comes in needs to be assigned to Jane Smith. BUT I do not know the names of the System Administrators.

So I need a way to count the duplicate entries and return whose name is listed the LEAST amount of time..

Any help would be greatful! I'm at a stand still.

Confused | :confused: Confused | :confused: Confused | :confused: Confused | :confused:
AnswerRe: Counting duplicate entries in an ArrayList Pin
Luc Pattyn26-Jul-08 8:10
sitebuilderLuc Pattyn26-Jul-08 8:10 
AnswerRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult26-Jul-08 8:20
mvePIEBALDconsult26-Jul-08 8:20 
GeneralRe: Counting duplicate entries in an ArrayList Pin
Jacob Dixon26-Jul-08 8:37
Jacob Dixon26-Jul-08 8:37 
GeneralRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult26-Jul-08 11:18
mvePIEBALDconsult26-Jul-08 11:18 
GeneralRe: Counting duplicate entries in an ArrayList Pin
Jacob Dixon26-Jul-08 12:53
Jacob Dixon26-Jul-08 12:53 
GeneralRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult26-Jul-08 18:04
mvePIEBALDconsult26-Jul-08 18:04 
JokeRe: Counting duplicate entries in an ArrayList Pin
Luc Pattyn26-Jul-08 13:18
sitebuilderLuc Pattyn26-Jul-08 13:18 
GeneralRe: Counting duplicate entries in an ArrayList Pin
Jacob Dixon26-Jul-08 13:29
Jacob Dixon26-Jul-08 13:29 
GeneralRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult26-Jul-08 17:59
mvePIEBALDconsult26-Jul-08 17:59 
GeneralRe: Counting duplicate entries in an ArrayList Pin
Luc Pattyn26-Jul-08 18:04
sitebuilderLuc Pattyn26-Jul-08 18:04 
GeneralRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult26-Jul-08 18:16
mvePIEBALDconsult26-Jul-08 18:16 
GeneralRe: Counting duplicate entries in an ArrayList Pin
Jacob Dixon27-Jul-08 6:40
Jacob Dixon27-Jul-08 6:40 
GeneralRe: Counting duplicate entries in an ArrayList Pin
PIEBALDconsult27-Jul-08 18:03
mvePIEBALDconsult27-Jul-08 18:03 
QuestionBackgroundWorker completes immediately [modified] Pin
#realJSOP26-Jul-08 6:32
professional#realJSOP26-Jul-08 6:32 
AnswerRe: BackgroundWorker completes immediately Pin
Mark Salsbery26-Jul-08 7:21
Mark Salsbery26-Jul-08 7:21 
GeneralRe: BackgroundWorker completes immediately Pin
#realJSOP26-Jul-08 7:27
professional#realJSOP26-Jul-08 7:27 
GeneralRe: BackgroundWorker completes immediately Pin
Mark Salsbery26-Jul-08 8:59
Mark Salsbery26-Jul-08 8:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.