Sort The Rows Randomly?
Oct 9, 2009How can i sort the rows randomly?
View 4 RepliesHow can i sort the rows randomly?
View 4 Repliesi would just like to ask how do i retrieve data rows in my table in my database randomly... i was able to create an online quiz wherein it displays the question,choices in consecutive order but what i want is, every time when user will start a quiz it will show questions in random order. I am using mssql 2005 as my database below is my code.. a
QuizPage.aspx
<asp:DetailsView ID="questionDetails" runat="server" AutoGenerateRows="False"
CellPadding="4" ForeColor="#333333"
GridLines="None" Height="50px" Width="550px">
[code]....
I need to sort the rows in a bindingsource. When I sort by a field name, ASC, it works correctly, but when I sort in DESC mode, instead of being the opposite of ASC, it sorts the rows whose fields have the same value in ASC order. For example:
I've got a column with the values A, B, P, P, P and P
ASC: A B P(1) P(2) P(3) P(4)
DESC (as i want it to be): P(4) P(3) P(2) P(1) B A
DESC (as it sorts):P(1) P(2) P(3) P(4) B A
Is there any property in bindingsource which I can use to change this?
how to sort the rows in one DGV by the color of the row...
I have 3 colors for all the rows based in the value of one field, the values are A,M,B that correspond to Red,White,Yellow colors. The Sort Order must be Red, White, Yellow when ascending and the inverse when descending...
I am trying to get the last 20 rows data from the sql db to the ListView from individual Name which i input to the txtbox. However it doesn't work out on the following way.
[Code]...
I want a macro to sort from A2 to xlLastCell on a sheet where the user will paste-in same-column but different-length data each month.I've just spend over 2 hours searching and found some neat code [and used some of what I found] but still have this question:How to replace E6191 with E(TotRows) in the below code? [code]
View 1 RepliesIn the following code all goes well until the .Sort line. Then I get an error which says, "The sort method is not valid. Make sure it is within the data you want to sort and the first sort by box isn't the same or blank."I've tried various permutations to deal with this exception, all to no avail. The Range is Selected ok and the Excel data are pasted from the clip board ok. Then I get the error and no sort occurs.
[code]...
How can I improve this bit below to make the items in the TreeView to sort faster or something totally different to sort them easier?
[Code]...
I have a MyObject; myObjects as List(Of MyObject) and a delegate Comparison(Of MyObject) that uses a lot of comparison functions (ByA, ByB, ByC etc) Ã la:
Shared Function CompareMyObjectsByName(x As MyObject, y As MyObject) As Integer
Return x.Name.CompareTo(y.Name)
End Function
[Code].....
Sub Sort()
ReDim RollsCC(NumOfPlayers - 1)
For N As Integer = 0 To (NumOfPlayers - 1)[code]....
Here I am creating a temp single dimensional array, merging my 2d array into it, and then attempting to sort it by Rolls(N,1), which is a integer 1-6, Everything seems to be working right with the exception of this.
RollsCC.Sort(RollsCC, 0, 1)
How would one specify a numeral sort based on the first character in the string? im aware that I am switching Rolls(n,1) and Rolls(n,0) information during the sort.
Currently my ListView sorts items by image.index. So 0 is at the top, then 1, 2 and so on. Think of it as an IRC chat room nick list. Ops at top then the rest are sorted alphabetically
[Code]....
I am working on Treeview control and Gridview Control VB.NET08. In the Treeview i have Parent and Child Nodes. Like:
- 31
3101
3102
[Code].....
I am working on Treeview control and Gridview Control VB.NET08. In the Treeview i have Parent and Child Nodes. Like: [Code] Comparing the Parent Node text and first two digits in the Column values. I want to add rows inbetween the gridview rows based on the parent and Child Nodes. If i expand the First Parent Node Called "31" then according to the Number of Child Nodes (for first parent node(31) there are 5 child nodes.) add rows in the gridview.
These New rows should be add under the 31-xxxx. If i expand the 32 Parent Node based on number of Child Nodes, add rows under the 32-xxxx. [Code] I am getting the rows in the end of the Gridrow not in the Specific row.
How would i delete only the successful inserted rows for insert and then move the non successful rows up and allow the user to correct the data and get it ready for an insert. If i dont delete the successful rows then i will have multiple inserts of the same dataRow and we dont want that! AND if i dont move the data up then it will have blank rows uptop and will end the try and not insert the corrected data. You can better see what logic i am trying to perform at the bottom of my code, right after I insert into the database. Here is my code.
Private Sub btnLaserGenerateTicket_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLaserGenerateTicket.Click
'Function declarations
[code]....
when populating a data grid i keep getting a redundant row in the bottom. is there a way to lock grid rows to the number of rows in the data table?
View 1 RepliesI have three sub tables that I want to process. For each I want to combine the rows, as they are only different by contents in the second column(I want to do the same to the fourth column, later):
'Sub table 1
xx|C201 |02300877 |Samsung |....
xx|C201 |02300877 |Toshiba |....
xx|C213 |02300877 |Samsung
[code]....
p.s. For the fourth column, Manufacturer information , I want to do the same and I'd probably get something like this for the final table:
xx| C201,C213,C606,C619 |02300877 | Samsung
xx| C201,C213,C606,C619 |02300877 | Toshiba
xx| C303, C305,C712 |02301163
xx| C207, C209, C708 |02301165
I am currently using DevExpress 10.2 within Visual Studio 2010. In a previous question I was trying to print the current user view of a DevExpress GridControl with the user's choice of expanded or collapsed master rows and/or group sections. I was told this was not possible at this time. I have now decided to use the following code:
[Code]...
How would i delete only the successful inserted rows for insert and then move the non successful rows up and allow the user to correct the data and get it ready for an insert. If i dont delete the successful rows then i will have multiple inserts of the same dataRow and we dont want that! :) AND if i dont move the data up then it will have blank rows uptop and will end the try and not insert the corrected data. Here is my code.
[Code]...
Public Shared Function isMatch(ByVal username As String) As Integer
For i As Integer = 0 To table.length - 1
Dim cellValue As String = table.getRow(i).getCell("Alias")
[Code].....
I have the code listed above as a translation from a Java snippet. The problem i have is that in Java, my table was stored as a dataset and as such, the methods were easily identifiable by "getRow" and getCell" using specific numbers and column names. However in VB the information is stored in an MS Access database (which i already have an open connection to, called: "_SalesPerformance_AnalyticsToolDatabaseDataSet12") and as such i do not know the correct way in which to iterate through each row in the database, checking a specific column against an already specified variable and then returning an integer based upon the value of a seperate column in the same row.
'Invoice Form
Dim daInvoice As New OleDbDataAdapter()
Dim dsInvoice As New DataSet()
Dim MyDataTable As DataTable
[code]...
Error...
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.
I have an Excel sheet that looks like this.
View 1 Replieshow to add Rows programmatically to the DataGridView's rows collection when the control is data-bound? here is my code but i got error as "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound? "
[Code]...
I am trying to sort an arraylist using .Sort() but am not sure what to put in the () for the field/column I want to sort on. Here is the portion of my code that creates the array from a SQL Query
[Code]...
Dim _tableBackLogs As System.Data.DataTable
Do While i - 2 > 0
_tableBackLogs = Global.DataAccess.GetDataTable("SELECT SubjectID,SubjectName,Grade FROM SubjectPI WHERE RegNo='" & CInt(HttpContext.Current.Session("userName")) & "' AND Status='Fail' AND Semester='" & i - 2 & "'")
i = i - 2
Doing this replaces the previous data in the DataTable. I want to retain the previous data i.e i want the new rows to be added to the DataTable w/o replacing the previous rows.
My DataGridView sorts by date. For grins I entered the date 11-02-2010 fully expecting it to be at the bottom of the list, not listed right after the last 11-02-2009 row and before the first 11-03-2009 row.How do I handle this so that come January 1, I won't see all the 01-01-2009 rows listed first followed by the 01-01-2010 rows then the 01-02-2009 rows, etc?
[code]...
Updated with newer answer and better test
Let's say I have the number 382 which is 101111110.
How could I randomly turn a bit which is not 0 to 0?
The why;
Since people ask me why, I simply need to do this, removing a bit from an integer.
based on the answer here is the result(working one I ran this [code]...
I am using the Array type .Sort function to sort my array.By default it places the result Array into Ascending order Least to Greatest How do I change that to Descending order Greatest to Least?and How do I change it to Closest to logic? or does that not exist?Assume there is an Array of Numbers 0,13,21,-2,4,5,1.34 and I want them to sort closest to 0 or some other arbitray value; the Output should look similar to:
0,1.34,-2,4,5,13,21
Our solution is built on ASP.NET v1.1 framework. User is presented with login form, so upon providing credentials this information is posted back to the server. Upon postback SessionID changes and our application crashes as some information which is required for processing is stored in the cache and is identified by SessionID string as a part of the name.
This SessionID change happens absolutely randomly and only to some of the clients. Most of the time browser used to view the page and post info is IE8. I cannot reproduce this issue in our test environment, as SessionID is persistent though-out the whole testing process.
I've already checked all solutions, i.e.
Session cache is used on Page_Load to retrieve/store some information, so it's initialized and contains data stored. I've made a Health Monitoring check on Application_End event to capture any possible AppDomain crashes using Reflection and Diagnostics Libraries and retrieving ShutDownMessage from httpruntime object, but that's also not a case. Cookieless attribute of the sessionState in web.config is set to false (using URL to store SessionID is not an option)
All MS security and bug fixes are installed on the server. IIS Server settings are similar to the ones we use in Test Environment.
I'm trying to configure my program to choose a random entry from an array:
Code:
MsgBox("Participants will now be allocated to each group at random...")
Dim number As Integer
Dim randomnumber As Integer
[Code].....
Protected Overrides Sub LoadForm()
MyBase.LoadForm()
Try
'StartProcess might be causing an error (error msg is issue with loading config, which would be incorrect)
StartProcess()
[Code] .....
I can run this 100 times under the exact same conditions and it seems like 40 times it will crash with the following error:
"Cannot access a disposed object. Object name: 'frmImportExport'."
It will either die on
'within StartProcess()
Dim __Delegate As New _Delegate(AddressOf StartProcess)
Me.Invoke(__Delegate)
or
Dim D As New _Delegate(AddressOf SOPERATION)
The form isn't being disposed manually anywhere that I see, and this code is being executed on formload. It's a subform that is to be displayed within a main form.