473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 7756
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
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...
7
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...
7
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...
2
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...
1
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...
1
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...
4
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...
3
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...
1
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 + "'))"; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.