473,714 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview - Convert Data Type in filterexpressio n

Hi,

I've got a Gridview utilizing a filterexpressio n:
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
OnDeleted="Item Deleted"

EnableCaching=" true" SqlCacheDepende ncy="APP_TIMESH EET:AB"
CacheKeyDepende ncy="AB"

SelectMethod="G etABs" TypeName="Retri eveABData" DeleteMethod="D eleteAB"

......... filterexpressio n="ID ='{0}' AND Status ='{1}'"
OnFiltering="Ob jectDataSource1 _Filtering">

<filterparamete rs>

<asp:controlpar ameter name="ID" ControlID="tbxS elAB" PropertyName="T ext"
defaultvalue="" />

<asp:controlpar ameter name="Status" ControlID="ddlF ilterStatus"
PropertyName="S electedValue" defaultvalue="" />

</filterparameter s> ......

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 filterexpressio n?

Thank you very much,

DD
Feb 10 '06 #1
2 7781
Hi,

Nevermind - found the solution:

filterexpressio n="CONVERT(ID,' System.String') LIKE '{0}' AND
CONVERT(Status, 'System.String' ) LIKE '{1}'"
OnFiltering="Ob jectDataSource1 _Filtering">

<filterparamete rs>

<asp:controlpar ameter name="ID" ControlID="tbxS elAB" PropertyName="T ext"
defaultvalue="" />

<asp:controlpar ameter name="Status" ControlID="ddlF ilterStatus"
PropertyName="S electedValue" defaultvalue="" />

</filterparameter s>


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

I've got a Gridview utilizing a filterexpressio n:
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
OnDeleted="Item Deleted"

EnableCaching=" true" SqlCacheDepende ncy="APP_TIMESH EET:AB"
CacheKeyDepende ncy="AB"

SelectMethod="G etABs" TypeName="Retri eveABData" DeleteMethod="D eleteAB"

........ filterexpressio n="ID ='{0}' AND Status ='{1}'"
OnFiltering="Ob jectDataSource1 _Filtering">

<filterparamete rs>

<asp:controlpar ameter name="ID" ControlID="tbxS elAB" PropertyName="T ext"
defaultvalue="" />

<asp:controlpar ameter name="Status" ControlID="ddlF ilterStatus"
PropertyName="S electedValue" defaultvalue="" />

</filterparameter s> ......

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 filterexpressio n?

Thank you very much,

DD

Feb 13 '06 #2
Hi,

Nevermind - found the solution:

filterexpressio n="CONVERT(ID,' System.String') LIKE '{0}' AND
CONVERT(Status, 'System.String' ) LIKE '{1}'"
OnFiltering="Ob jectDataSource1 _Filtering">

<filterparamete rs>

<asp:controlpar ameter name="ID" ControlID="tbxS elAB" PropertyName="T ext"
defaultvalue="" />

<asp:controlpar ameter name="Status" ControlID="ddlF ilterStatus"
PropertyName="S electedValue" defaultvalue="" />

</filterparameter s>


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

I've got a Gridview utilizing a filterexpressio n:
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
OnDeleted="Item Deleted"

EnableCaching=" true" SqlCacheDepende ncy="APP_TIMESH EET:AB"
CacheKeyDepende ncy="AB"

SelectMethod="G etABs" TypeName="Retri eveABData" DeleteMethod="D eleteAB"

........ filterexpressio n="ID ='{0}' AND Status ='{1}'"
OnFiltering="Ob jectDataSource1 _Filtering">

<filterparamete rs>

<asp:controlpar ameter name="ID" ControlID="tbxS elAB" PropertyName="T ext"
defaultvalue="" />

<asp:controlpar ameter name="Status" ControlID="ddlF ilterStatus"
PropertyName="S electedValue" defaultvalue="" />

</filterparameter s> ......

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 filterexpressio n?

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
6550
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 or Insert
7
14810
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 but how is this done now in asp.net 2.0?
7
5470
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 looping through the GridView, it doesn't
2
8102
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 app and everything worked great - not a single line of code written yet. Then I wanted to add a...
1
6514
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 rows. The user now skips some pages by clicking a view times on the next icon. Now he changes the...
1
1655
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 added a little code that set the FilterExpression property of the SqlDataSource, and that seemed...
4
7341
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 SQLDataSource and re-binds the GridView. That worked great until I enabled paging. When paging is...
3
5176
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 the filterexpression. For example, this filterexpression works great:
1
6080
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 exception:
0
8801
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7953
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3158
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
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.