Gridview - Convert Data Type in filterexpression

D

DummyDumb

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
 
D

DummyDumb

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>
 
D

DummyDumb

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top