Forms Data Controls :: Filtering Data In A Grid Using SQLDataSource ControlParameter?
Mar 17, 2011
I have a gridview tied to a sqlDataSource. I want to filter it using FilterExpression of SqlDataSource. The controlParameter that I want to use is dropdownList SelectedItem.Value. This value is an integer. I am getting this exception: System.Data.EvaluateException:{"Cannot perform '=' operation on System.Int32 and System.String."}
[Code]....
View 3 Replies
Similar Messages:
Jul 24, 2012
I have a catalog function whereby user can filter their selection by clicking radiobutton. For example, by selecting the Dining radiobutton, all packages related to dining would appear.And i using DataList1.Items. Count method to count the number search result. I had implement this method in the page_load, however the value of the number of datalist keep displaying previously loaded datalist. Here is my code :
protected void Page_Load(object sender, EventArgs e)
{
DataList1.DataSourceID = "SqlDataSource3";
Label1.Text = DataList1.Items.Count.ToString();
[code]....
View 1 Replies
Feb 15, 2011
When i click on a row in gridview1, i want to go to gridview2 with the id i get from first grid.
How to get id from gridview1 to gridview2 and gridview2 autobinding?
View 4 Replies
Feb 4, 2011
I have this code in an .aspx file, within a sqldatasource control.
<asp:controlParameter
Name="WH"
ControlID="rblWH"
DefaultValue="DL"
Type="String"
Size="2"
Which currently uses a 2 character code from a radio button list as its value. It is used as a parameter for a stored procedure. Somewhere else on the page I have a combobox called cbTripPick with that 2 character code embedded within its text property. I wish to use that 2 character substring as the control parameter instead of the above. Can I do something like this ?
<asp:controlParameter
Name="WH"
ControlID="cbTripPick"
PropertyName = "some function or expression or eval that will give me the 2 char. value from the cbTripPick control"
DefaultValue="DL"
Type="String"
Size="2" />
Is it possible to declaratively set the propertyname to some dynamic expression which will get me what I want? Or should this all be done programmatically?
View 4 Replies
Mar 14, 2010
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.
View 3 Replies
Nov 2, 2010
I have a SqlDataSource that calls a stored procedure and it works fine. If I add a <ControlParameter> tag to add an additional argument, then the query never fires and the databinding never occurs.
This works:
[Code]....
When I add the ControlParameter, the databinding no longer occurs:
[Code]....
The ControlParameter refers to a valid object on the page.
View 1 Replies
Mar 1, 2011
I am having a problem with using A Gridview SectedIndex or value in a sql ControlParameter. When I select the row it does what I need it to except it shows that there is no data.
but if I add Default Value of 1 the data shows up, but it needs to read from the Gridview.
[Code]....
I even added sqlDataSource.DataBind() in the SelectedIndexChanged Event to see if that would fix it but - No! I used it with a DropDown and it worked only when I use AutoPostBack = true of course.
View 3 Replies
Jul 2, 2010
I am working on a project and I need to use Master/Details view, the problem is everything works fine except when I place the Master (gridview) and Details(FromView) in different content holder.
The error I get is:
Could not find control 'GridView1' in ControlParameter 'ID'.
Description:
An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find control 'GridView1' in ControlParameter 'ID'.
My code is:
[Code]....
[Code]....
[Code]....
[Code]....
View 2 Replies
Mar 11, 2010
I have an ObjectDataSource with a number of parameters. These parameters are binded in my FormView EditItemTemplate and the ItemTemplate. My Stored Procedure column names in my ItemTemplate are different to the Bind properties used in the EditItemTemplate. This is obviously throwing an exception when I update a record.
Instead of using Bind("Columne Name") in my EditItemTemplate how do I use a ControlParameter to reference a TextBox in the EditItemTemplate?
I may be wrong but I'm trying to use the PropertyName=Controls but i do not know how to reference the Textbox in the EditItemTemplate.
View 9 Replies
Jan 24, 2011
i'm using Relational Tables and during Edit, my Drop Down list is a lookup column from the Master table, but when i try to edit it works and shows the records the only problem is that when i udpate, i get the error (Can't find control DDLSongs (my drop down control) in @AlbumID Parameter) below is the code for ref.
<asp:GridView
ID="grdSongs"
runat="server"
DataSourceID="srcSongs"
DataKeyNames="SongId"
AutoGenerateColumns="false"
[Code]....
View 5 Replies
Dec 12, 2010
i have two tables (Albums,Photos).befor i want insert a record in a Photo table i must select name of album so i create a user control that have a dropdownlist and a datasource(Albums table) until when i select a name of album put AlbumID in a Property(SelectedValue) when i use this user control in details view in edittemplate i have an error
--->error could not find control 'SelectedAlbum' in ControlParameter 'AlbumID' my code id:
public partial class Admin_SelectedAlbum : System.Web.UI.UserControl
{
public string [COLOR="Red"]SelectedValue[/COLOR] {
get { return DropDownList1.SelectedValue; }
}
protected void Page_Load(object sender, EventArgs e)
{.........
how does AlbumID (photo table) set with value of property(SelectedValue) of Usercontrol?
View 2 Replies
Apr 12, 2010
I have following in many controls:
<asp:ControlParameter Name="SvcCluster_Id" ControlID="frmConfigEdit$ddlCluster" PropertyName="SelectedValue" />
Everything was good before I bumped into the problem when declarative binding (SelectedValue='<# Bind("SvcCluster_Id") >') produced the error, because value has not been found in the list. So i moved binding to the code:
protected void frmConfigEdit_DataBound(Object sender, System.EventArgs e)
{
if (frmConfigEdit.CurrentMode == FormViewMode.Edit)
{
var svcCluster_id = DataBinder.Eval(frmConfigEdit.DataItem, "SvcCluster_id");
var ddlCluster = (DropDownList)frmConfigEdit.FindControl("ddlCluster");
if (svcCluster_id != null && ddlCluster.Items.FindByValue(svcCluster_id.ToString()) != null)
{
ddlCluster.SelectedValue = svcCluster_id.ToString();
}
}
}
But now seems like this happens later than ObjectDataSource tries to access frmConfigEdit$ddlCluster...
How to manage this?
I wouldn't like to move everything to the code (I mean creating Control parameters, etc)
p.s. Oops, actually it works ok for DataBound event! Sorry.
View 2 Replies
Sep 21, 2010
I have this code:
<asp:GridView ShowFooter="true" DataSourceID="odsRooms" Width="700" DataKeyNames="id,locationid" ID="gvRooms" GridLines="None" PageSize="10" runat="server" AllowSorting="true" AllowPaging="True" CellSpacing="4" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Bottom" >
<ItemTemplate>
<%# Eval("roomname")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbRoomname" MaxLength="20" Text='<%# Eval("roomname")%>' runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Bottom">
<ItemTemplate>
<%# Eval("sqmeters")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbSqmeters" MaxLength="6" Width="60" Text='<%# Eval("sqmeters")%>' runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" >
<ItemTemplate>
<%# Eval("persreception")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbPersreception" MaxLength="6" Width="60" Text='<%# Eval("persreception")%>' runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Bottom" >
<ItemTemplate>
<%# Eval("persdiner")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbPersdiner" Text='<%# Eval("persdiner")%>' MaxLength="6" Width="60" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Bottom" >
<ItemTemplate>
<%# Eval("persparty")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbPersparty" Text='<%# Eval("persparty")%>' MaxLength="6" Width="60" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Bottom" >
<ItemTemplate>
<%# Eval("descriptiontext")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="tbDescriptiontext" Text='<%# Eval("descriptiontext")%>' TextMode="MultiLine" Rows="2" Columns="28" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="true" DeleteText="Delete" ShowEditButton="true" EditText="Edit" CancelText="Cancel" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsRooms" InsertMethod="InsertRoom" DeleteMethod="DeleteRoom" UpdateMethod="UpdateRoom" runat="server" SelectMethod="GetLocationRoomsPagedSorted" SelectCountMethod="GetLocationRoomsCount" SortParameterName="sortExpression"
TypeName="locationsBLL" EnablePaging="true">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="tbRoomname" PropertyName="Text" Name="roomname" Type="String" />
<asp:ControlParameter ControlID="tbSqmeters" PropertyName="Text" Name="sqmeters" Type="String" />
<asp:ControlParameter ControlID="tbPersreception" PropertyName="Text" Name="persreception" Type="String" />
<asp:ControlParameter ControlID="tbPersdiner" PropertyName="Text" Name="persdiner" Type="String" />
<asp:ControlParameter ControlID="tbPersparty" PropertyName="Text" Name="persparty" Type="String" />
<asp:ControlParameter ControlID="tbDescriptiontext" PropertyName="Text" Name="descriptiontext" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
And get this error when I click 'Edit' and then 'Update':
Server Error in '/' Application. Could not find control 'tbDescriptiontext' in ControlParameter 'descriptiontext'.Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find control 'tbDescriptiontext' in ControlParameter 'descriptiontext'.
Source Error:
[Code]....
Stack Trace:
[Code]....
[InvalidOperationException: Could not find control 'tbDescriptiontext' in ControlParameter 'descriptiontext'.]
System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +2961386
System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +152
System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +113
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +47
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +1204
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +3636597
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1336
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +641
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +164
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
View 1 Replies
Jan 16, 2011
i have one grid and one button when i click on that button then it expand and showing another grid under the row of parent grid how to do that.
View 2 Replies
Apr 10, 2010
I've got a GridView populated via a SqlDataSource whose Select command is controlled by a DropDownList. This is all working nicely:
How do I support the "All" user choice:
In other words, when the user selects "All" there are no aircraft names that match that so nothing is returned. Instead, I'd like the select statement to skip the WHERE clause in this case and just show everything. Do I need to create a second page for this case or is there a way to programmatically alter the SELECT command or some other way to accomplish this?
View 4 Replies
Apr 11, 2010
I have made an ASP.NET page with a ListView which binds to a Linq datasource which have inserting, updating and deleting enabled. All very trivial and well designed by MS. It all works very well so far.
Now I add a DropDown control to the page and binds the Linq datasource Where clause to the dropdown using the following code:
[Code]....
Now I can filter the listview based on the DropDown control. It works very well and I can still insert and delete rows in the ListView.
PROBLEM:
However when the DropDown control is used to filter the ListView rows I can no longer use the Editing functionality of the ListView. The row never goes into editing mode when the Edit button is clicked.
When the DropDown is not used for filtering - is in default state - editing works as expected.
View 2 Replies
Mar 18, 2011
I have a table with 500 rows and when I try to display them all, the response is really slow (local server). The situation gets even worse when I try to sort the results by a specific field. The filtering process is done in a store procedure by passing the parameters.
Well, here is my code:
[Code]....
I have 2 textboxes (start/end dates) and 2 listboxes which I use to filter my data. Here is my goal:
-make the response faster;
-including paging (does paging bring all the data or it fetches the data as I click on a specific page?)
View 1 Replies
Feb 4, 2011
I have an SqlDataSource at the moment, which I want to be able to be filtered using 3 DropDownList's. Basically, each DropDownList contains values for a certain column on the table, so when they choose one of the values, the SqlDataSource only shows values with that value in the relevant column.
So my table is somewhat like this:
ID (primary key)
ManufacturerID
ItemTypeID
UnitTypeID
And the 3 DropDownList's contain the following:
Manufacturers (value = ManufacturerID)
ItemTypes (value = ItemTypeID)
UnitTypes (value = UnitTypeID)
My filter expression for the datasource is currently like this, but it doesn't seem to work unless all 3 boxes have a value selected, which is not ideal. Any ideas guys? My filterexpression is below:
ItemTypeID = {0} OR ManufacturerID = {1} OR UnitTypeID = {2} OR (ItemTypeID = {0} AND ManufacturerID = {1}) OR (ItemTypeID = {1} AND UnitTypeID = {2}) OR (ManufacturerID = {1} AND UnitTypeID = {2}) OR (ItemTypeID = {0} AND ManufacturerID = {1} AND UnitTypeID = {2})
View 1 Replies
Sep 21, 2010
I have made site with datalist and I want to use SQL data filtering and paging, my only problem is that i want to put filtering into paging procedure
paging 1)
Alter Procedure dbo.GetProductsPaged
View 2 Replies
Sep 29, 2010
This seems like a stupid, basic question, but I can't find how to do it (plus I've been doing MVC and haven't done in webforms in ages now) - I've got a DataList object that hooks into an SQLDataSource object, and this works fine. However I need to create a second DataList object for a slightly different set of criteria. Rather than creating a second SQLDataSource object and thus calling the DB twice, I would like to make my SQLDataSource object return a broader set of results (this is easy as I am searching on a column, then each DataList is further filtering on another column) and then further filter these results on each respective DataList - how do I do this?
View 5 Replies
Mar 29, 2011
I've been filtering my gridviews with the FilterExpression of the underlying ObjectDataSource etc. I am wondering how I can implement filtering on my GridViews if I just directly databind it to a datatable etc?
View 5 Replies
Jan 28, 2010
I need to filter data in a View using three dropdownlists that are populated independently of one another. The items in the second ddl are not based on the items in the first, etc. Each ddl is populated using its own sql statement. I want to be able to use each of these dropdownlists independently of the other two, but I want the data that is returned to be based on the values already in the other dropdownlists when I make a selection change.
For example: DDL1 is populated with Horsepower values from its own SQL statement.
DDL2 is populated with Gallons per Minute from its own SQL statement, unrelated to what is chosen in DDL1.
DDL3 is populated with Diameter values from its own SQL statement, unrelated to either of the other DDLs.
I want to be able to make a selection from any of the DDLs and filter data based on the selection, and whatever the current value is for the other two DDLs.
I'm coding in C# and I think I may need to create a delegate and an event to listen for when the SelectedIndexChanged event fires on any of the DDLs. This is slightly more complicated than anything I've coded up to this point, I'm a beginner, and I'm not even sure I'm aiming in the right direction for a solution.
View 8 Replies
Jun 9, 2010
I want to filter my gridview using two parameters that come from Dropdownlists. I bind these drops with two linq queries and next I would like to filter my gridview with query that has two parameters that comes from selected values from those drops. Everything is inserted in UpdatePanel. Here is my code:
asp:UpdatePanel
ID="UpdatePanel1"
runat="server"
>
[Code]....
I don't know how to get selectedvalues from dropdownlist and pass them to Bind() function which binds grid view
View 3 Replies
Dec 30, 2010
I am trying to populate a gridview that returns only the logged in users' records. Specifically, I am getting a blank page when I load the page. To clarify, I get the blank page after successfully logging in to the ASP.Net Membership and do have data to return from the requested table.
I am reaching out to the online community after numerous failed attempts to research the solution and successfully return the desired results through trial and error variations.
ASPX Page
[Code]....
ASPX.vb CodeBehind
[Code]....
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
View 4 Replies
Jan 27, 2010
I'm using a GridView with an ObejctDataSource. The data is provided by a business object and not a DB. It returns a list of people and each person belongs to a group. Now I need to filter data. For example, I need to return list of people in specific groups. How can I specify a list of groups to be able to filter the data ? Could I use SQL like syntax ? I understand the filter expression works only when data is returned as a datatable. But in my business object I maintain data as hashtables and return as List<PeopleInfo>. Do I need to return list as datatable instead ?
View 2 Replies