473,526 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview - Convert Data Type in filterexpression

Hi,

I've got a Gridview utilizing a filterexpression:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OnDeleted="ItemDeleted"

EnableCaching="true" SqlCacheDependency="APP_TIMESHEET:AB"
CacheKeyDependency="AB"

SelectMethod="GetABs" TypeName="RetrieveABData" DeleteMethod="DeleteAB"

......... filterexpression="ID ='{0}' AND Status ='{1}'"
OnFiltering="ObjectDataSource1_Filtering">

<filterparameters>

<asp:controlparameter name="ID" ControlID="tbxSelAB" PropertyName="Text"
defaultvalue="" />

<asp:controlparameter name="Status" ControlID="ddlFilterStatus"
PropertyName="SelectedValue" defaultvalue="" />

</filterparameters> ......

where TbxSelAB is a TextBox and ddlFilterStatus is a DropDownList.

The corresponding Database columns are both of type integer. Applying the
above filter results in an error as both parameters are of type string. Is
there any way to make a type conversion in the filterexpression?

Thank you very much,

DD
Feb 10 '06 #1
2 7771
Hi,

Nevermind - found the solution:

filterexpression="CONVERT(ID,'System.String') LIKE '{0}' AND
CONVERT(Status,'System.String') LIKE '{1}'"
OnFiltering="ObjectDataSource1_Filtering">

<filterparameters>

<asp:controlparameter name="ID" ControlID="tbxSelAB" PropertyName="Text"
defaultvalue="" />

<asp:controlparameter name="Status" ControlID="ddlFilterStatus"
PropertyName="SelectedValue" defaultvalue="" />

</filterparameters>


"DummyDumb" <DummyDUmb> wrote in message
news:u$*************@TK2MSFTNGP10.phx.gbl...
Hi,

I've got a Gridview utilizing a filterexpression:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OnDeleted="ItemDeleted"

EnableCaching="true" SqlCacheDependency="APP_TIMESHEET:AB"
CacheKeyDependency="AB"

SelectMethod="GetABs" TypeName="RetrieveABData" DeleteMethod="DeleteAB"

........ filterexpression="ID ='{0}' AND Status ='{1}'"
OnFiltering="ObjectDataSource1_Filtering">

<filterparameters>

<asp:controlparameter name="ID" ControlID="tbxSelAB" PropertyName="Text"
defaultvalue="" />

<asp:controlparameter name="Status" ControlID="ddlFilterStatus"
PropertyName="SelectedValue" defaultvalue="" />

</filterparameters> ......

where TbxSelAB is a TextBox and ddlFilterStatus is a DropDownList.

The corresponding Database columns are both of type integer. Applying the
above filter results in an error as both parameters are of type string. Is
there any way to make a type conversion in the filterexpression?

Thank you very much,

DD

Feb 13 '06 #2
Hi,

Nevermind - found the solution:

filterexpression="CONVERT(ID,'System.String') LIKE '{0}' AND
CONVERT(Status,'System.String') LIKE '{1}'"
OnFiltering="ObjectDataSource1_Filtering">

<filterparameters>

<asp:controlparameter name="ID" ControlID="tbxSelAB" PropertyName="Text"
defaultvalue="" />

<asp:controlparameter name="Status" ControlID="ddlFilterStatus"
PropertyName="SelectedValue" defaultvalue="" />

</filterparameters>


"DummyDumb" <DummyDUmb> wrote in message
news:u$*************@TK2MSFTNGP10.phx.gbl...
Hi,

I've got a Gridview utilizing a filterexpression:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OnDeleted="ItemDeleted"

EnableCaching="true" SqlCacheDependency="APP_TIMESHEET:AB"
CacheKeyDependency="AB"

SelectMethod="GetABs" TypeName="RetrieveABData" DeleteMethod="DeleteAB"

........ filterexpression="ID ='{0}' AND Status ='{1}'"
OnFiltering="ObjectDataSource1_Filtering">

<filterparameters>

<asp:controlparameter name="ID" ControlID="tbxSelAB" PropertyName="Text"
defaultvalue="" />

<asp:controlparameter name="Status" ControlID="ddlFilterStatus"
PropertyName="SelectedValue" defaultvalue="" />

</filterparameters> ......

where TbxSelAB is a TextBox and ddlFilterStatus is a DropDownList.

The corresponding Database columns are both of type integer. Applying the
above filter results in an error as both parameters are of type string. Is
there any way to make a type conversion in the filterexpression?

Thank you very much,

DD

Feb 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6534
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update...
7
14787
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1...
7
5460
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when...
2
8093
by: Bill Manring | last post by:
I am writing a very simple web application using VS 2005 and a SQL Server Database. I am just starting to experiment wth .NET 2.0 and I am trying out the supposedly improved databinding. I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the...
1
6495
by: Henry Habermacher [MVP Access] | last post by:
Environment: VS2005, ASP.Net 2.0, SQLServer 2000, VB.Net, IIS6 I use a GridView Control which is based on a SQLDataSource. The datasource is based on a Select statement and is filtered by the FilterExpression. The GridView also has a pager element (below, displaying first, previous, next, last icons), paging is enabled, page contains 10...
1
1650
by: Andrew Nav | last post by:
I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a single line of code written yet. Then I wanted to add a simple feature where the user could filter out data based on a value in a single column. I...
4
7334
by: Bishop | last post by:
I have a number of simple select queries that a user needs to be able to execute and display the data on the screen in a gridview. My thought was that I could use a Gridview set to dymanically generate columns and bound to a SQLDataSource. Then the user can click buttons (or whatever) and it changes the SelectCommand property of the...
3
5153
by: Curt | last post by:
I have a gridview object with a sqldatasource as its sourceid. Everything was going so well until I came across this problem. My SELECTCOMMAND for my sqldatasource is: select alertid,subject,createdt,eventid,eventname, statuscd,trgid from vwAlerts order by createdt desc Now, based on a fiew input fields, I put together a WHERE clause for...
1
6051
by: pnbaocuong | last post by:
Dear All When I try to use convert function of MS sql server like this: String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))"; PAYROLLDataSet.WORKINGTIMESRow workingtime_row = (PAYROLLDataSet.WORKINGTIMESRow)pAYROLLDataSet.WORKINGTIMES.Select(sql); Whe I run, it rais bellow...
0
7329
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7253
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7651
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3317
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1702
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
890
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.