Hi,
I am binding Entity DataSource to RadGrid. Now the problem is when adding a new record, it throws "Specified cast is not available" Exception. it works fine for edit operation. I tried checking for null in getter of the property but the problem remains there. I am not able to figure out the problem.
Ragards,
Thank you in advance,
I am binding Entity DataSource to RadGrid. Now the problem is when adding a new record, it throws "Specified cast is not available" Exception. it works fine for edit operation. I tried checking for null in getter of the property but the problem remains there. I am not able to figure out the problem.
| <telerik:RadGrid ID="radProjectGrid" runat="server" AutoGenerateColumns="false" DataSourceID="entProjectDataSource" |
| AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" |
| Skin="Default" OnItemCommand="radProjectGrid_ItemCommand" |
| onitemcreated="radProjectGrid_ItemCreated"> |
| <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="Project_ID" |
| DataSourceID="entProjectDataSource"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridBoundColumn UniqueName="Project_Title" HeaderText="Project Title" DataField="Project_Title" |
| SortExpression="Project_Title"> |
| <HeaderStyle Width="150px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="150px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ProjectLeader_Name" HeaderText="ProjectLeader Name" |
| SortExpression="ProjectLeader_Name" UniqueName="ProjectLeader_Name"> |
| <HeaderStyle Width="120px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="120px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn UniqueName="Location" HeaderText="Location" DataField="Location" |
| SortExpression="Location"> |
| <HeaderStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn UniqueName="Start_Date" HeaderText="Start Date" DataField="Start_Date" |
| DataType="System.DateTime" SortExpression="Start_Date" DataFormatString="{0:MM/dd/yyyy}"> |
| <HeaderStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="End_Date" DataType="System.DateTime" HeaderText="End Date" |
| SortExpression="End_Date" UniqueName="End_Date" DataFormatString="{0:MM/dd/yyyy}"> |
| <HeaderStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="80px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridCheckBoxColumn DataField="IsVisible" DataType="System.Boolean" HeaderText="ShowOnWebsite" |
| SortExpression="IsVisible" UniqueName="IsVisible"> |
| <HeaderStyle Width="60px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| <ItemStyle Width="50px" HorizontalAlign="Left" VerticalAlign="Middle" Wrap="true" /> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <EditColumn UniqueName="EditCommandColumn1"> |
| </EditColumn> |
| <FormTemplate> |
| <div style="float: left"> |
| <table> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Project Title: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtProjectTitle" runat="server" Text='<%# Bind("Project_Title") %>'></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Location: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtLocation" runat="server" Text='<%# Bind("Location") %>'></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Project Leader Name: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtProjectLeader" runat="server" Text='<%# Bind("ProjectLeader_Name") %>'></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Start Date: |
| </td> |
| <td class="tdRightAdmin"> |
| <telerik:RadDatePicker ID="rdpStartDate" runat="server" AutoPostBack="false" MinDate="01/01/1000" |
| MaxDate="01/01/3000" DbSelectedDate='<%# Bind("Start_Date", "{0:D}") %>' /> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| End Date: |
| </td> |
| <td class="tdRightAdmin"> |
| <telerik:RadDatePicker ID="rdpEndDate" runat="server" AutoPostBack="false" MinDate="01/01/1000" |
| MaxDate="01/01/3000" DbSelectedDate='<%# Bind("End_Date","{0:D}") %>' /> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Website: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtWebsite" runat="server"></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| ShowOnWebsite |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("IsVisible") %>'/> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| <asp:Button ID="btnUpdate" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' |
| Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' /> |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" |
| Text="Cancel" /> |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div style="width: 450px; float: right;"> |
| <table> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Goal: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtGoal" runat="server" Text='<%# Bind("Goal") %>' TextMode="MultiLine"></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Objective: |
| </td> |
| <td class="tdRightAdmin"> |
| <asp:TextBox ID="txtObjective" runat="server" Text='<%# Bind("Objective") %>' TextMode="MultiLine"></asp:TextBox> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Project Image: |
| </td> |
| <td class="tdRightAdmin"> |
| <telerik:RadUpload ID="radUploadProjectImage" runat="server" ControlObjectsVisibility="None" |
| TargetFolder="~/Images"> |
| </telerik:RadUpload> |
| </td> |
| </tr> |
| <tr> |
| <td class="tdLeftAdmin"> |
| Leader Image: |
| </td> |
| <td class="tdRightAdmin"> |
| <telerik:RadUpload ID="radUploadProjectLeaderImage" runat="server" ControlObjectsVisibility="None" |
| TargetFolder="~/Images"> |
| </telerik:RadUpload> |
| </td> |
| </tr> |
| </table> |
| </div> |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| <ClientSettings> |
| <ClientEvents OnRowDblClick="RowDblClick" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
Ragards,
Thank you in advance,