|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ObjectDataSource ControlParametersI 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:objectdatasource 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:objectdatasource> Have you tried setting ConvertEmptyStringToNull within parameter to
false explicitly? <asp:ControlParameter ConvertEmptyStringToNull="false" Type="String" ControlID="txtFullName" PropertyName="Text" /> jeremy.brews***@akqa.com wrote: Show quoteHide quote > 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:objectdatasource 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:objectdatasource> 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 CaffieneR***@gmail.com wrote: Show quoteHide quote > Have you tried setting ConvertEmptyStringToNull within parameter to > false explicitly? > > <asp:ControlParameter ConvertEmptyStringToNull="false" Type="String" > ControlID="txtFullName" PropertyName="Text" /> > > jeremy.brews***@akqa.com 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:objectdatasource 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:objectdatasource> You're welcome.
I don't use that attribute myself but handle nulls seperately in my DAL. Andy jeremy.brews***@akqa.com wrote: Show quoteHide quote > 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 > > > CaffieneR***@gmail.com wrote: > > Have you tried setting ConvertEmptyStringToNull within parameter to > > false explicitly? > > > > <asp:ControlParameter ConvertEmptyStringToNull="false" Type="String" > > ControlID="txtFullName" PropertyName="Text" /> > > > > jeremy.brews***@akqa.com 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:objectdatasource 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:objectdatasource>
dropdown list post back not working
Treeview SelectedNodeStyle Problem Wizard control in 2.0 and dynamic items Passing values to user controls - naughty problem Why it doesn't work? web controls install Problem with ASP.NET wizard hiding / removing steps problem with hidden field from a custom control in a form Can't access webpage's controls from the code-behind file after putting it in a <asp:LoginView/> Interrogating cells on current row for GridView |
|||||||||||||||||||||||