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

Bound grid

3 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
al
Top achievements
Rank 1
al asked on 17 Aug 2009, 04:02 AM
Hi everyone! i have a scenarion here.
I have a grid and i used GridTemplateColumn and used the the input object for the binding.

<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Selected">
 <ItemStyle Width="1%" VerticalAlign="Top"></ItemStyle>
         <ItemTemplate>
                 <input type="radio" name="rbStatisticalValue" value='<%# CastValue(DataBinder.Eval(Container.DataItem, "ID")) %>'
                         <%# SetCheckedStatusForRadioBtn(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Selected"))) %>/>
 </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="ListOrder">
     <HeaderTemplate>List Order</HeaderTemplate>
     <ItemStyle Width="1%" VerticalAlign="Top"></ItemStyle>
     <ItemTemplate>
          <input type="text" value='<%# CastValue(DataBinder.Eval(Container.DataItem, "ListOrder"))%>' readonly="readonly"  maxlength="3"/>
     </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Title">
     <HeaderTemplate>Options</HeaderTemplate>
     <ItemStyle Width="1%" VerticalAlign="Top"></ItemStyle>
     <ItemTemplate>
          <input type="text" value='<%# CastValue(DataBinder.Eval(Container.DataItem, "Title"))%>'/>
     </ItemTemplate>
</telerik:GridTemplateColumn>


when i click on the Add New Record on the grid, i got this error
"Object cannot be cast from DBNull to other types"

I cannot figure out whats causing this error...

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 17 Aug 2009, 12:23 PM
Hi al,

Most probably the error is in this line:

SetCheckedStatusForRadioBtn(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Selected")))

you can check this using the debugger.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
al
Top achievements
Rank 1
answered on 18 Aug 2009, 01:31 AM
Hi Vlad! Thanks for the reply! I have already tried removing then SetCheckedStatusForRadioBtn(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Selected"))) %>/ and place '<%DataBinder.Eval(Container.DataItem, "Selected") %>/', but still, am getting that error.
0
Vlad
Telerik team
answered on 18 Aug 2009, 06:12 AM
Hi al,

Can you verify using the debugger where is this error? Can you post the stack trace?

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
al
Top achievements
Rank 1
Answers by
Vlad
Telerik team
al
Top achievements
Rank 1
Share this question
or