I would like a textbox to show nothing if the value coming from the database is NULL.
Currently, it is a number so it shows '0'. If the value is '0', I would like it to show nothing.
Using the GetValueJavaScript attribute, can you write add an if statement to the this attribute?
Thanks.
Yes, there is a way, you can try this approach:
<ig:RowEditingClientBinding ColumnKey="Date" ControlID="control_Date" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value} == null ? '' : {value}" />
Let me know about the results.
The script is ignored because I was using the wrong attribute...Duh!
If I do this:
SetValueJavascript="$get({ClientID}).value={if (value == null) {' '} else {value}}"
I get a syntax error.
Is there any way to check for a null value and then set the value to the empty string instead of a '0' displaying?
I have tried adding this javascript to the GetValueJavascript attribute, but it is ignored. This is the code:
GetValueJavaScript="var LatValue = $get({ClientID}).value; if(LatValue == null){ $get({ClientID}).set('value', ''); } else { $get({ClientID}).value; }"
Sorry for the confusion...
I am setting values in my RowEditing Template by binding using the ClientBindings. Below is what I am currently doing for the latitude and longitude values:
<Behaviors> <ig:RowEditingTemplate CancelButton="buttonCancelEdit" OKButton="buttonOKEdit"> <ClientBindings> <ig:RowEditingClientBinding ColumnKey="Lat" ControlID="txtLatEdit" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> <ig:RowEditingClientBinding ColumnKey="Long" ControlID="txtLongEdit" GetValueJavaScript="$get({ClientID}).value" SetValueJavaScript="$get({ClientID}).value={value}" /> </ClientBindings> <Template> <table id="tblEdit" style="width: 800px; border: 1px solid Black; background-color:White;"> <tr> <td align="left" style="width: 15%;"> <asp:Label ID="lblLatEdit" runat="server" Text="Latitude: " /> </td> <td align="left" style="width: 35%;"> <asp:TextBox ID="txtLatEdit" runat="server" Width="200px" /> <asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server" MaskType="Number" TargetControlID="txtLatEdit" Mask="99.999999999" AcceptNegative="Left"> </asp:MaskedEditExtender> </td> <td align="left" style="width: 15%;"> <asp:Label ID="lblLongEdit" runat="server" Text="Longitude: " /> </td> <td align="left" style="width: 35%;"> <asp:TextBox ID="txtLongEdit" runat="server" Width="200px" /> <asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" MaskType="Number" TargetControlID="txtLongEdit" Mask="99.999999999" AcceptNegative="Left"> </asp:MaskedEditExtender> </td> </tr> </table> </Template></ig:RowEditingTemplate></Behaviors>
This works fine if there are values in the Lat and Long elements. However, if the values from the database are NULL, they are shown as '0'. I want NULL values to display as an empty string, not 0.
Can I add a conditional statement in the attribute, GetValueJavaScript to set the TextBox for Lat and Long to the empty string if the values are NULL?