cast is not valid on a three toggle state rad button inside a grid

7 posts, 0 answers
  1. Georges
    Georges avatar
    6 posts
    Member since:
    Sep 2016

    Posted 08 Sep Link to this post

      <telerik:GridTemplateColumn UniqueName="ORACLE_VERIFIED" HeaderText="Oracle">
                            <ItemTemplate>
                                <telerik:RadButton RenderMode="Lightweight" Checked='<%#Bind("ORACLE_VERIFIED")%>' ID="btnToggleOracle" runat="server" ToggleType="CustomToggle" ButtonType="ToggleButton"
                                    AutoPostBack="false">
                                    <ToggleStates>
                                        <telerik:RadButtonToggleState Text="Not Verified" Value="0" PrimaryIconCssClass="rbToggleCheckbox" Width ="100px"/>
                                        <telerik:RadButtonToggleState Text="N/A" Value="-1" PrimaryIconCssClass="rbToggleCheckboxFilled" Width ="100px"/>
                                        <telerik:RadButtonToggleState Text="Verified" Value="1" PrimaryIconCssClass="rbToggleCheckboxChecked" Width ="100px"/>
                                    </ToggleStates>
                                </telerik:RadButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>

     

    i am trying to bind a three state toggle button and getting cast not valid. the values are 0,1,-1 if not available. this is oracle and the fields are defines as int in c# . anyone ran into this issue before? thanks

  2. Georges
    Georges avatar
    6 posts
    Member since:
    Sep 2016

    Posted 08 Sep in reply to Georges Link to this post

    Checked='<%# (DataBinder.Eval(Container.DataItem,"ORACLE_VERIFIED").ToString()=="-1" ?"N/A":Eval("ORACLE_VERIFIED")) %>'

     

    i changed it to this and still getting an error, cast error

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Georges
    Georges avatar
    6 posts
    Member since:
    Sep 2016

    Posted 08 Sep Link to this post

    Checked='<%# (DataBinder.Eval(Container.DataItem,"ORACLE_VERIFIED").ToString()=="-1" || DataBinder.Eval(Container.DataItem,"ORACLE_VERIFIED") is DBNull ?"N/A":Eval("ORACLE_VERIFIED")) %>'

    1) checked gives me the cast error

    2) values does not and it does not bind

    3) Dbvalue does not but it does not bind either..

    not sure what the issues is with cast. could be the last EVAL that needs to be casted to boolean?

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 13 Sep Link to this post

    Hello,

    You get this due to the fact that Value is null and Bind() expression will try to assign this to Checked property. You need to have default value (1/0/-1) for Value

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Georges
    Georges avatar
    6 posts
    Member since:
    Sep 2016

    Posted 13 Sep in reply to Maria Ilieva Link to this post

    i get you but no one is giving me example on how to write the syntax, i keep getting errors on different syntax. can you show me an example using my code above.
  7. Georges
    Georges avatar
    6 posts
    Member since:
    Sep 2016

    Posted 13 Sep in reply to Maria Ilieva Link to this post

    the actual value is coming back as -1. there is not null but i keep getting cast value error. it does not know how to interpret -1 i guess
  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 16 Sep Link to this post

    Hi,

    Try setting the values as Text instead of using the Value property and see how it goes.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017