DataList / PagedDataSource / DataTable - How To Allow For Filter Control Parameter?
Apr 18, 2010
Prior to adding paging using PagedDataSource I had dropdownlist and search box filters for my DataList. The guts of the code in aspx page for those parameters is below:
When creating the pager using PagedDataSource I did a tutorial which did not have parameters and all the code went in the code behind page. The guts of it is below:
The pager is great but now I need to add my filters. The page wont load if I add the "SelectParameters" code (above) to my aspx page and if I simply add the "WHERE" clause to the "SELECT" clause in the code behind I get an error stating that I need to add a scalar variable.
I have found some examples through googling but nothing specific enough.
Prior to adding paging using PagedDataSource I had dropdownlist and search box filters for my DataList. The guts of the code in aspx page for those parameters is below:
HTML Code:
[code]....
The pager is great but now I need to add my filters. The page wont load if I add the "SelectParameters" code (above) to my aspx page and if I simply add the "WHERE" clause to the "SELECT" clause in the code behind I get an error stating that I need to add a scalar variable.
I want to filter the DataTable. for filtering the the datatable I am passing the string parameter which contains multiple wildcards ( e.g. string strSearchValue = "test%str%g")
I am trying to get paging to work on a DataList bound to a DataSet, using SQL stored procedures, with and without parameters, and without using querystrings.
I allow visitors of the page to filter the DataList by either selecting a value from various dropdowns e.g to see products of a certain supplier on the page or by clicking hyperlinks e.g to show all products.
The problem is paging isn't working at all. The next and previous buttons are not changing the page. However, I am not getting any error messages.
Here's my code. Note I have excluded all my dropdown methods that simply call getData and pass relevant parameters. However the default dataset view should still work.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI;
Dim dt As New DataTable Dim da As New SqlDataAdapter(s, c)
c.Open() if Not IsNothing(da) Then da.Fill(dt)
[code]...
When I call da.fill I am inserting all records from my query. I was then hoping to filter them to display only those where the GroupingID is equal to 0. When I run the above code. I am presented with all the data, the filter did not work. Please can you tell me how to get this working correctly.
One of our customers has a report with a single value string parameter that has over 1000+ possible values. selecting single value from 1000+ choices results in bad UI, among other things.create another parameter that acts a filter for the other parameter. So you would have Param1 with say 25 choices and selecting a choice would narrow down the option for the second parameter.Is this the best way. What is the best practice for handling these kinds of parameters?
Many times I need to manipulate with DataTable after I get data from database using adapter.Fill(table).
Usually I calculate data in DataTable by using loops. But I know that there is simpler way using LINQ. I know some basics about that just for strongly typed objects.I can't find how to do this with DataTable that is not strongly typed. How could I get all DataRow or Filtered DataTable (not just value for the field) from table for that conditions:
- where the specified field of the table contans MAX/MIN/AVG value, - where the specified field of the table equals to some value.
I create a DataTable and filter it. When I use filter1, everything works as expected. When I use filter2, everything works as expected only if the SubsectionAmount variable is less than 10. s soon as I set SubsectionAmount=10, the dr2 array returns Nothing.
Imports System.Data Partial Class FilterTest Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Loa [code]....
I am doing some aggregates on in memory tables using the DataTable.Compute method. It works file if there is only one filter, however when there is multiples then it does not work.
This first one works fine the second one does not.
I have to develop an authorize filter in asp.net mvc.I have got five categories of users in my site and my site uses custom created authentication system.Now i have a controller action which should be accessible to 3 out of those five type of users.How to create a filter (basically authorize) and use it which fulfills my requirement?I think i need to create the authorize filter with parameter.I should be able to use something like this in my controller action.
Authorize[UsersType="admin,accountant,operator"] public ActionResult Test() { }
I've built a User Control that contains a ListView. To make it work I need to pass to it a DataTable. The columns of this DataTable need to have particular names that match up with what the ListView is expecting. I have a large DataTable that I need to massage/convert over to this different format. To do that I need to filter out columns and rename the column names. The actual data in the DataTable doesn't need to change. Is there a good way to do this without actually instantiating a new DataTable and copying the data from the large DataTable into it?
I would like to implement LINQ IN ASP.NET for filter required data from datatable. I have doubt that what is right place. I have following options
At presentation layer *.aspx.cs
At our Business layer.
At our Data base layer, where query for database happen which is return as a datatable to business layer. Business layer then return the result to presentation layer.right place for LINQ because now i have to further filter data from datatable as per user selecter filters.
[URL]as the iage upstairs i have to create a filter in my sql stored procedure so, my difficulties is switch the "and" and "OR" paramers located in the webFormhow can i do that?i was thinking to save in a temporaney variable : @temp='and field=1' but my difficulties is to concatenate with a principal query and execute it
i could bind the data form tables to dropdownlist in asp .net using linq.
ex: var res=from n in dc. contacts where n.location==Hyd select new{n.Id,n.Name}; var res1=from n in dc. Morecontacts where n.location==Hyd select new{n.Id,n.Name}; dropdown1.Datasouce=res; dropdown1.DataTextField="Name"; dropdown1.DataValueField="Id";
I have a ListView with Checkbox. My requirement is - When I click on any checkbox then it should return all the columns values of that row on behalf of that CheckBox. After much study I came to know that using DataTable and DataRow I can get all data of particular ID of a Row. But I am unable to work with this. My code is something like below:
I thought this would be easy and maybe it is but it's eluding me.
In an action filter (MVC 2) I want to add/edit one of the parameters for the type I'm passing to my action method.
I have an action method:
[Code]....
Bar is a simple class for viewData:
[Code]....
In my BarFilter action filter OnActionExecuting method I want to add a value for paramA which is not set by the view so that Bar will be fully populated in my Foo action method. I've tried various methods of adding values to ViewData, ModelState, Model etc. but I always get a null returned in Foo.
protected void btn_showReport_Click(object sender, EventArgs e) { //ReportViewer1.Visible is set to false in design mode ReportViewer1.Visible = true;
[Code].....
Parameter 'Comp_Name' does not exist on this report
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Parameter 'Comp_Name' does not exist on this reportSource Error:
I have jquery menu in index.aspx page when user click on item related to that item it go to House.aspx and show products information in datalist these are my table in DB:
1-House_info Table
Id Behcode Name Region H_name
1 1111 Jack 1 Cloth 2 2222 Ana 1 Electric 3 3333 Edvard 2 Electric 4 4444 Math 1 Furniture
2-House_product Table
Id Behcode Name Description H_name
1 2222 Iron Test Electric 2 4444 Sofa Test Furniture 3 1111 Scarf Test Cloth 4 3333 Laundry Test Electric
And these are my code in index.aspx and House.aspx
string Code = Request.QueryString["H_name"]; SqlCommand _cmd = new SqlCommand("select * from House_p where H_name=@H_name", _cn); _cmd.Parameters.AddWithValue("@H_name", Code); _cn.Open(); SqlDataReader _dr = _cmd.ExecuteReader();
[Code] ...
EX : In index.aspx When user click on Electric item it go to house.aspx and show all product that have H_name=Electric According to House_p table it will show :
Id Behcode Name Description H_name
1 2222 Iron Test Electric 4 3333 Laundry Test Electric
Now I have one DDL and 1 button in House.aspx page I want when user click on menu and go to house.aspx page after they see result of their selected item from menu choose their region from ddl and click on button after that they see product that are in that region according to table House_info
EX : If user select region 1 it will show all Electric product that have region=1
Am using northwind sql server database to do a test. Using customer, order table to show master detail report. Customerid is the reference. After Create a Parameter to run the subreport. Some how i cant able to refernce the master, detail. so it will show all the records in the detail section instead of showing relevant customer id details from the orders table. pls see the picture belowMainreport - > call the subreport parameter. but i miss with one more step to finish the report "Filter Expression", i guess. how to pass the parameter value subreport filter.