ObjectDataSource ControlParameters

  • Thread starter jeremy.brewster
  • Start date
J

jeremy.brewster

Hello

I have an ObjectDataSource object on a webform, and the
ObjectDataSource object includes a series of asp:ControlParameter
object as SelectParameters. Some of these ControlParameter object
refer to drop-down lists and some refer to asp:TextBoxes.

My problem is that to be able to use an existing business layer object,
I want to be able to pass zero-length strings for each asp:TextBox that
is left empty. These values keep being passed as nulls. Is there any
way to intercept each TextBox value and set the value to String.Empty
if the TextBox is empty? I've tried intercepting the values in the
Select event but I cannot override the value from there.

<asp:eek:bjectdatasource id="ObjectDataSource1" runat="server"
typename="Business.UserManager" selectmethod="FindUserSearch"
onselecting="ObjectDataSource1_Selecting"
oninit="ObjectDataSource1_Init">
<selectparameters>
<asp:controlparameter name="membershipNumber" type="Int32"
controlid="MembershipNumberTextBox" propertyname="Text" />
<asp:controlparameter name="userSecurityRoleId" type="String"
controlid="SecurityRoleDropDownListControl1"
propertyname="SelectedValue" />
<asp:controlparameter name="firstName" type="String"
controlid="FirstNameTextBox" propertyname="Text" />
<asp:controlparameter name="surname" type="String"
controlid="SurnameTextBox" propertyname="Text" />
<asp:controlparameter name="email" type="String"
controlid="EmailTextBox" propertyname="Text" />
<asp:controlparameter name="postcode" type="String"
controlid="EmailTextBox" propertyname="Text" />
<asp:controlparameter name="isActive" type="Boolean"
controlid="StatusDropDownList" propertyname="SelectedValue" />
</selectparameters>
</asp:eek:bjectdatasource>
 
C

CaffieneRush

Have you tried setting ConvertEmptyStringToNull within parameter to
false explicitly?

<asp:ControlParameter ConvertEmptyStringToNull="false" Type="String"
ControlID="txtFullName" PropertyName="Text" />
 
J

jeremy.brewster

Hi

Yes, I tried that yesterday evening and everything now works. I hadn't
stumbled across this property until I created a test object data source
using the designer and saw the interactive means of setting
ConvertEmptyStringToNull.

Thanks

Jez
 
C

CaffieneRush

You're welcome.
I don't use that attribute myself but handle nulls seperately in my
DAL.

Andy
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top