IComparer For ArrayList.sort?
Feb 28, 2010How to compare array in arraylist by name.I try many thing but no one works.public class myReverserClass : IComparer { int IComparer.Compare( Object x, Object y ) { ... }
View 1 RepliesHow to compare array in arraylist by name.I try many thing but no one works.public class myReverserClass : IComparer { int IComparer.Compare( Object x, Object y ) { ... }
View 1 RepliesI am trying to implement sorting in list using IComparer Interface.
If any two values are equal, then there order is not maintained in the list
after using sort function.
Say, I am sorting an Employee object based on Department ID like,
Employee 1 -> Dept ID = 100, Name = "John"
Employee 2 -> Dept ID = 100, Name = "Peter"
Employee 3 -> Dept ID = 100, Name = "Wills"
The output of this after sorting based on Department ID should be
100, John
100, Peter
100, Wills
but the output is
100, Wills
100, Peter
100, John
where the order is getting changed if the values in the sort column are equal.
Is it possible to maintain the order if the elements are equal.
i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.
View 6 RepliesI have a simple dynamic gridview with following code -
GV = new GridView();
Actually i want to ask which is the best for sorting in Asp.Net is it DataView.Sort Method or List<Object>.Sort() method.
View 1 RepliesI'm looking for a way to sort the rows of a datatable without setting the DefaultView.Sort to a specific column. I have a datatable in session that users can add records to. I want them to be able to sort the data by clicking on a button. But new records added after that need to show up at the bottom of the list until the sort button is clicked again.
View 2 RepliesJust spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
I tried this:
Tried setting gridview1.sqldatasourceid = null; gridview1.allowsorting = false; gridview1.databind();
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery:
[Code]....
i read Matt Berseth article also i downloaded this source. But i can not do sorting event. Everything is ok but sorting is not working.
[Code]....
I am looping through a dataset and I would like to have the following in this array list
name, from, to, price
john, 40, 50, 39.99
mike, 20, 50, 49.99
etc.
Once I do that, or if it is possible to do it using the dataset that will work with me. But I want to do...
If john's price between from and to...
So in my code I wanted to make it easy for me and instead of memorizing the row #, I would just do.. arraylist.row("john").item("from")
How can I convert a arraylist to a string?
View 4 RepliesIs there a way I can sort this query result in Linq? I'd like to sort in descending order by the .Count parameter:
[Code]....
I have an arraylist of string items that I want to bind to a gridview.I want to bind the value from each item to a asp:HyperLinkField but I dont know what the DataTextField should be? The arraylist obviously doesn't have a column heading as it's just 1 dimensional.What value do I need to use in the DataTextField?
View 3 Replieshow to distinct arraylist value using c#?
View 10 RepliesI have ArrayList in my Model and want to iterate through it in my javascript. I am using following code but its giving me error : CS0103: The name 'i' does not exist in the current context
for(var i=0; i <= <%=Model.KeyList.Count%>; i++)
{
alert('<%=Model.KeyList[i]%>');
}
How to get rid of this?
how can i do empty Arraylist in immediate window in asp.net
View 1 RepliesIs there an easy way of storing an ArrayList containing different custom objects? I guess the easiest way for me would be to use a foreach to store each object into our database, but how would I read them out of the db and assigning them to the correct class?
View 8 Replieshow can i delete all arraylist item?
View 6 RepliesI have three ArrayLists with string elements and I want to store them into one List/ArrayList/String Array/Dictionary.
I mean I want to add them. I don't know which one How can I do it? What should I use?
It is in asp.net/c#.
I have a problem with how to fill an array list from a data reader
string queryDTL = " SELECT * FROM tbl1 ";
connection.Connect();
cmd = new OracleCommand(queryDTL, connection.getConnection());
dr_DTL = qcmd2.ExecuteReader();
ArrayList RecordsInfo = new ArrayList();
while (dr_DTL.Read())
{
RecordsInfo = dr_DTL["number"].ToString();
}
The problem is the datareader contain alot of info other than the number but I don't know how to put them in their correct position.
I have an Array List to save selected files and a ListBox to display only the name of the files..my requirement is to delete corresponding files from arraylist when its deleted from listbox...here is my code:
public ArrayList to_compress = new ArrayList();
ListBox pack_lbx=new ListBox();
private void add_btn_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
[Code]....
I have a gridview with a column of checkboxes. On checking the checkboxes, they have to click on a drop down list that will redirect them to another page. The value of the checkboxes are stored in an arraylist. However, the problem is how can i pass the arraylist to the redirected page?
View 2 RepliesCan i store Image data in Array list.
View 4 RepliesI am trying to retrieve a arraylist frm a session and add in more objects into the arraylist on top of the existing object in the arraylist.But i have encounter problem at the foreach loop where it promted me a error message shown below
Object reference not set to an instance of an object.
below are the sample code.
public void addItemToArraylist(List<LibraryItem> temp) //l temp pass in 5 items each tim
{
ArrayList storeItems = new ArrayList();
storeItems = (ArrayList)Session["storeItems"];
foreach (LibraryItem items in temp)
[Code]....
I have a function and I am getting an error message. I need to convert my DataTable to an array and be able to access each line individually. This is the error message: Operator '-' is not defined for types 'System.Data.DataRowCollection' and 'Integer'.
[Code]....
I have a procedure that is used to look up user permissions in our custom table, There is 1 record for each user and about 20 columns for each of the permissions.
How can i take the column values and place into an array?
All the column are bit type and 1 is int. Is it possible to take the values returned and add to an ArrayList?
And then once the values are in the array, how to loop thru it and go to certain index to check the value.
This is what i have now:
[Code]....
[Code]....
[Code]....