CodeSmith Community
Your Code. Your Way. Faster!

Basic question on deleting from EntityGridView

Latest post 12-15-2006 1:39 PM by Robert Hinojosa. 1 replies.
  • 12-14-2006 6:00 PM

    • fooster
    • Not Ranked
    • Joined on 05-27-2005
    • Posts 2
    • Points 40

    Basic question on deleting from EntityGridView

    I think I'm missing something really basic here.

    I have an entity gridview bound to a typed datasource- this is the generated admin page using 13/Nov/06 nightly templates. The entity has multiple foreign keyed relations. Nothing happens when I select delete. Its obviously choking on the foreign key colections. So my question is how do I perform a delete from an entitygridview- along with any FK relations. The only changes i have made to the generated code is I removed some of the bound columns to better suit the admin interface.

    Thanks

     
    Ben 

     Code follows:

     
         <data:GridViewSearchPanel runat ="server" ID="SearchPanel" GridViewControlID="GridView1" BusinessEntityType="FTS.Entities.Hotels" />   
            <data:EntityGridView ID="GridView1" runat="server"           
                AutoGenerateColumns="False"                   
                OnSelectedIndexChanged="GridView_SelectedIndexChanged"
                DataSourceID="HotelsDataSource"
                DataKeyNames="HotelID"
                AllowMultiColumnSorting="false"
                DefaultSortColumnName=""
                DefaultSortDirection="Ascending"   
                ExcelExportFileName="Export_Hotels.xls"
                AllowExportToExcel="true"                
                >
                <Columns>
                    <asp:CommandField ShowSelectButton="True" ShowEditButton="True" showDeleteButton="true" />               
                    <asp:BoundField DataField="HotelName" HeaderText="HotelName" SortExpression="HotelName"  />
                    <asp:BoundField DataField="HotelCode" HeaderText="HotelCode" SortExpression="HotelCode"  />
                    <asp:TemplateField HeaderText="DestinationID">
                    <ItemTemplate>
                            <asp:Repeater ID="DestinationID1" runat="server" DataSourceID="DestinationsFilter1">
                                <ItemTemplate>
                                    <%# Eval("DestinationName") %>
                                </ItemTemplate>
                            </asp:Repeater>

                            <data:EntityDataSourceFilter ID="DestinationsFilter1" runat="server"
                                DataSourceID="DestinationsDataSource1"
                                Filter='<%# String.Format("DestinationID = {0}", Eval("DestinationID")) %>'
                            />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="HotelRating" HeaderText="HotelRating" SortExpression="HotelRating"  />
                    <asp:checkboxfield DataField="IsLive" HeaderText="IsLive" SortExpression="IsLive"  />
                    <asp:checkboxfield DataField="FeatureOnHomePage" HeaderText="FeatureOnHomePage" SortExpression="FeatureOnHomePage"  />
                </Columns>
                <EmptyDataTemplate>
                    <b>No Hotels Found!</b>
                </EmptyDataTemplate>
            </data:EntityGridView>
            <br />
            <asp:Button runat="server" ID="btnHotels" OnClientClick="BLOCKED SCRIPTlocation.href='/FTS/admin/HotelsEdit.aspx'; return false;" Text="Add New"></asp:Button>
               
            <data:DestinationsDataSource ID="DestinationsDataSource1" runat="server"
                SelectMethod="GetAll"
            />
            <data:MetrosDataSource ID="MetrosDataSource2" runat="server"
                SelectMethod="GetAll"
            />
            <data:MetrosDataSource ID="MetrosDataSource3" runat="server"
                SelectMethod="GetAll"
            />
            <data:HotelsDataSource ID="HotelsDataSource" runat="server"
                SelectMethod="GetPaged"
                EnablePaging="True"
                EnableSorting="True"
            >
                <Parameters>
                    <data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
                    <data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
                    <asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex" Type="Int32" />
                    <asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize" Type="Int32" />
                    <data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
                </Parameters>
            </data:HotelsDataSource>
                    

     

     

    • Post Points: 35
  • 12-15-2006 1:39 PM In reply to

    Re: Basic question on deleting from EntityGridView

    You can either turn on cascading deletes for that table to it's fk relationships.  Or you will have to handle that using the Deleting event of the DataSource control.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems