This is a migrated thread and some comments may be shown as answers.

Inconsisant template rendering - SelectedValue which is invalid Error

5 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 11 Jan 2015, 07:41 PM
Hi,

Running into something very odd.  I have a radgrid using a custom EditForm template.  The bound recordset has a field called Status, containing zero through five.  inside the template i have the following code.  Basically I need to show this section if the Status is zero, anything else and it's not rendered.

<% If CheckStatus() Then%>
<fieldset>
  <legend class="Legend">Options</legend>
  <table style="width: 100%;">
    <tr>
      <td class="tableData">
        <asp:RadioButtonList ID="chkboxSaveOptions" runat="server" SelectedValue='<%# Bind("status") %>'>
          <asp:ListItem Value="1">SUBMIT</asp:ListItem>
          <asp:ListItem Selected="True" Value="0">Save as draft</asp:ListItem>
        </asp:RadioButtonList></td>
    </tr>
  </table>
</fieldset>
<%End If%>


The issue, sometime when I click to edit the row the If Then is never evaluated.  I set a breakpoint in CheckStatus.  Sometimes the breakpoint is hit and it work fine, sometimes it just renders the template without ever triggering the breakpoint and errors out because the status value isn't in the Buttonlist values.

I have no idea as i cant find a pattern.

Thanks.

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Jan 2015, 09:13 AM
Hello,

What you can try is adding the code inside Panel with Visible='<%= CheckStatus %>' and see what will be the result.

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Frank
Top achievements
Rank 1
answered on 19 Jan 2015, 12:10 AM
Hi,

Thanks, that was a good idea.  However, a new issue;  really odd.  Now the for next loop never finds the current edited item to retrieve the Status from...  The are items in the collection and it does loop but the If Then never fires

For Each item As GridDataItem In RadGridGrievances.MasterTableView.Items
               If item.Edit Then
                   Status = item("status").Text
               End If
Next
0
Frank
Top achievements
Rank 1
answered on 19 Jan 2015, 01:20 AM
further testing reveals the for next is always one short.  Going to move the visibility control to code-behind and see if that solves it.
0
Frank
Top achievements
Rank 1
answered on 19 Jan 2015, 03:04 AM
Hi,

Having a hard time working around this.

I tried this as an alternative method....
<asp:Panel ID="pnlDraftControl" runat="server" Visible='<%# IIf(Eval("status").Equals(0), "True", "False") %>'>
it works, but the twist, the value of status can be as high as 5.  the button list only represents 0 & 1.  If i edit a record with status of 1, the radiobuttonlist is hidden.  if the value of status is 2 or higher i get the following error. 

'rbnSaveOptions' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
0
Frank
Top achievements
Rank 1
answered on 19 Jan 2015, 03:31 AM
I found a workaround. I wouldn't call it a solution so if someone has a better method i would like to hear.

I used the IIF in the Panel and added the values 0 through 5 as RadioButtonList Items.  It appears when i need it too and doesn't throw an error when status is > 1.
Tags
Grid
Asked by
Frank
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Frank
Top achievements
Rank 1
Share this question
or