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.
Hello Gloria,
Thank you for using our forums.
By default our WebDataGrid is showing null values as empty strings. I don't know what do you mean by saying textbox? Do you mean some of our editor providers? Could you please share with me more information about your concerns, like exact product version and some code snippet of your Grid.
Looking forward to hearing from you.
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?