ObjectDataSource ControlParameters

Discussion in 'ASP .Net Web Controls' started by jeremy.brewster@akqa.com, Jul 5, 2006.

  1. Guest

    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>
     
    , Jul 5, 2006
    #1
    1. Advertising

  2. Guest

    Have you tried setting ConvertEmptyStringToNull within parameter to
    false explicitly?

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

    wrote:
    > 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>
     
    , Jul 6, 2006
    #2
    1. Advertising

  3. Guest

    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


    wrote:
    > Have you tried setting ConvertEmptyStringToNull within parameter to
    > false explicitly?
    >
    > <asp:ControlParameter ConvertEmptyStringToNull="false" Type="String"
    > ControlID="txtFullName" PropertyName="Text" />
    >
    > wrote:
    > > 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>
     
    , Jul 6, 2006
    #3
  4. Guest

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

    Andy

    wrote:
    > 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
    >
    >
    > wrote:
    > > Have you tried setting ConvertEmptyStringToNull within parameter to
    > > false explicitly?
    > >
    > > <asp:ControlParameter ConvertEmptyStringToNull="false" Type="String"
    > > ControlID="txtFullName" PropertyName="Text" />
    > >
    > > wrote:
    > > > 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>
     
    , Jul 6, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. WertmanTheMad

    objectDataSource

    WertmanTheMad, Sep 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    378
    WertmanTheMad
    Sep 15, 2004
  2. WertmanTheMad

    Arrrrg !!!! ObjectDataSource Issues

    WertmanTheMad, Oct 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,239
    WertmanTheMad
    Oct 8, 2004
  3. =?Utf-8?B?RG9u?=

    ObjectDataSource

    =?Utf-8?B?RG9u?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    435
    =?Utf-8?B?RG9u?=
    Nov 22, 2004
  4. Microsoft news
    Replies:
    2
    Views:
    9,314
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    266
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page