DataSource Controls :: Filtering / Selecting Rows Based On Date?
Aug 26, 2010
I have a gridview, based on thsi datasource:
Using a dropdownlist, I can filter (by changing datasource) the results based on customer names in a dropdownlist. This datasource, working perfectly, looks like this:
Now, using a textbox and a ajax calendar, I would like to be able to filter on the date as well, but my datasource so far:
doesn't work very good. In some case sit doesnt show anything, in onther situations - with 10 records for a given date, it only shows one.
Question one: How do I make the last datasource work? Its probably - again-again - something with the datetime formats, but for the life of me, I can't see how to do.
Question two: The Ideal solution would be using the first datasource, SqlDataSourceAllLoads, and then be able to filter the results with filterexpressions/parameters, but again, how? The filterparameters would origin from a DropDownListKunder, matching the tblDeliveredInfo.deliveryInfo_FirmaNavn as seen in the second datasource, while the date comes from the textbox txtStartDate (databinding fired by a button).
I am writting a directory website that advertises fitness classes. These classes are listed by Class Type, and Geographical Area. Each Class Type can satisfy one or more of four Fitness Goals such as Loose Weight etc...
I have a table for Classes (classid, classname, classdesc, classtypeid, geoareaid) I have a table for geographic areas (geoareaid, geoarea) And I have a table for ClassTypes (classtypeid, classtypename, classtypedesc)
Which obviously links geographic area via the classes.geoareaid as a forgien key and classtypes by classes.classtypeid as a forgien key.
I can list all classes by type and also by geo area no problem, the problem arrises when I then also want to filter by goal.
The Goals Table (goalid, goal, goaldesc) is linked to the classtypes table via another table classtypes_goals (classtypeid, goalid) as each classtype can satisfy any of the 4 goals.
I am using a DataSet to fetch the data from a Stored Procedure in the SQL Database but because the classtypes can be linked to multiple goals I am getting duplication in my list depending on how many goals a classtype satisfies.
All I need in my data list is class name, class type and area I don't even need to display the goal I just want a drop down above the table that will filter the list and show only classes of classtype that satisfy the goal chosen.
I save dates as a string in a varchar data field named "TilDato" in a SQLServer-express table. I want to filter the records smaller than a specific date from a variable in the script. I try the following statement, but it does not seems function logically.
objCmd = new SqlCommand("SELECT * FROM Reservering WHERE @laanedato<=TilDato",myConn2); objCmd.Parameters.Add("@laanedato", laanedato); objRdr = objCmd.ExecuteReader();
I am having a staff table which contain staff information on it. To search staff information from the table, I want to prefer filter style. For example in the select query I want to display staff information according to three criterias. Select staff information from all sections, Select staff information from a given section, select staff information by a given Name. All these selects must be performed in a single select statement. Suppose,
SELECT * FROM StaffDetailsTbl WHERE SectionID = CASE WHEN @SectionFilter IS NULL THEN [SELECT ALL] ELSE SectionID = @SectionFilter and Name = CASE WHEN @NameFilter IS NULL THEN [SELECT ALL] ELSE Name Like '%@NameFilter%'
Where Declared variables are parameterized stored procedure values retrieved from the user.
I have a standard gridview, with the standard paging and sorting interface enabled.The application holds appointments for three organisational units, with a maximum of 3000 appointment records being returned across all three units. The appointment records are quite small.
The choice I am faced with is to:
1. Have an Org Unit dropdown which returns to the datasource on change of selection and at inital databind, and returns appointment records for one org unit at a time i.e. approx 1000 records.
2. Have the objectdatasource return all 3000 appointment records for all org units at initial databind, and filter the objectdatasource by org unit on change of selection, thereby saving a trip to the datasource.
I guess the question boils down to identifying the point at which querying the datasource by org unit is more efficient than filtering the records returned by org unit.
Is 3000 records a lot for a gridview to be paging and sorting etc.
Here is the query I have now which returns over 2 million records:
This works, but the result is littered with many rows that contain the same SSN. So how do I return only one row for each ssn? I cant use distinct because all of the other columns are already always different, this would return the same as above.
I'm trying to filter data based on the selected value from a drop down list and the according values of a local variable within a gridview_rowdatabound event. For example, if "In Arrears" is selected, the gridview should return all rows where the account balance is less than -100. So far, when I select a value from the dropdown list, it has no effect on the gridview. Here's the code I have:
If (DropDownList1.SelectedIndex = 0) Then e.Row.Visible = True ElseIf ((DropDownList1.SelectedIndex = 1) And (AccountBalance <= -100)) Then e.Row.Visible = False ElseIf ((DropDownList1.SelectedIndex = 2) And (AccountBalance > 100) And (AccountBalance < -100)) Then e.Row.Visible = False End If
Now i want to do that user cannot select end date less than start date , e.g if he choose 2-July-2014 ( as a start date) then he could not choose (1-July-2014) as End date , dates prior to Start Date must get disabled in End Date Calendar Extender.
How do you select value from a gridview? I would like to pass values of rows selected to a query with the code below, but the grid seems to be frozen and I can't find a property for the grid that allows me to select rows.
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged Dim DB As New AOP29DBDataContext If GridView1.SelectedValue = "Receiver" Then Dim Query = From p In DB.Receivers Select p GridView2.DataSource = Query GridView2.DataBind() End If If GridView1.SelectedValue = "Donor" Then Dim Query = From p In DB.Donors Select p GridView2.DataSource = Query GridView2.DataBind() End If End Sub
Here what i am trying to accomplish. I want to have a div or panel on the page and have some text on it. The div or panel must hava a specfied time limit and then disaaper from the page. Say i want this text to apper on 10Cotober 10.00 and disapper from the page on 11October 18.00.
I am using a gridview in (Visual Studio 2010) to display records from a SQL 2005 database. I can filter my date range successfully but it does not include the end date. I have tried using the between expression as well as >= <= to return the dates from the beginning and end dates. I have search and found that this is due to the time portion of my datstamp in the SQL column (02/19/11 01:03:36 PM) where I am filtering by short date (02/19/11); therefore leaving the end date out of the records returned.
Now the solution I have read is to add a day onto the endate like this: 02/19/11 + 1 but I get a conversion error returned from the SQL server. I have tried to use convert in this matter to convert the textbox.text in the selectcommand to datetime 101 formats to overcome this but I must still be missing something because it comes back with another SQL error unable to convert nvchar to datetime.
In the end I would like to have my two textboxes StartDate - EndDate filter the dateStamp column in my Transactions table and if both textboxes have the same date return records for that date only and include the EndDate if the range is more than one day.
I have tried many different variations of the below code using $,#,+ and & symbols to encapsulate the EndDate controlparameter to add a day to the EndDate and have failed at all attempts.
This my markup that filters fine excluding the EndDate;
I have tried using this as well and work excluding the EndDate:
selectcommand="Select * from Transactions where DateStamp Between @StartDate and @EndDate">
i have two sqldatasource controls. one i use to display data in textbox's ,filter'd by a select parameter in page behind code. Once checked, i want to copy this data to the other datasource ,by selecting checkbox.Then display this data in detailsview control.
At present the two datasource controls declared , render data to the page simultaneously during pageload. I want to first check data in textbox's from first source, before second datasource is rendered to screen. note, both are filtered by a page variable. i wish to leave the textbox datasource control in situ, as other controls and code depend on it.The other detailsview datasource is my problem?
I currently have a common file that's responsible for exporting the users GridView to a CSV file which works fine, mostly. The problem is that it only exports the current gridview display, and being that I have it paged, it can be cumbersome to get all the data to an excel sheet when there can be upwards of 20 pages of data. The GridView has a LINQ datasource as follows
How do I get the results of the preceeding datasource? Or is there a better way to get ahold of that data before it is paged?
I right click on a TableAdapter, select Add Query, select using QueryBuilder, then select a field to filter upon, and add Filter as =@BookStem. Automatically the QueryBuilder adds the WHERE clause to my new query:HERE (BookStem = '@BookStem')When I press OK, I get "BookStem in expression is not part of the query". And filtering doesn't work.
This is not straight forward to explain but basically i want to only get the current weeks data in a table, i.e. if its say thurs or fri and i run the report i just want to filter from the previous Monday every time.
I dont want to use a parameter because there is another table that i want to see ALL data from way back.
So, if i ran the report today (28th april), the table would show Monday (26th), Tuesday (27th) and today Wed (28th).