Unable To Delete In RadGrid . Binding By Ms-access

4 posts, 1 answers
  1. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 31 Oct 2010 Link to this post

    I Have a Radgrid but I am Unable to delete the Items On Runtime .There is delete option near the values but still the action does not take place. Can anyone tell me why ? Here is my Code 
      <telerik:RadGrid ID="RadGrid1" runat="server"
       AllowPaging="True" GridLines="None"
       Skin="Office2007"
       DataSourceID="AccessDataSource1" AllowAutomaticDeletes="True"
      AllowAutomaticInserts="True" AllowAutomaticUpdates="True" PageSize="8">
    <MasterTableView AutoGenerateColumns="False" DataSourceID="AccessDataSource1">
    <RowIndicatorColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn>
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="Name" DefaultInsertValue=""
                HeaderText="Name" SortExpression="Name" UniqueName="Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Email" DefaultInsertValue=""
                HeaderText="Email" SortExpression="Email" UniqueName="Email">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Details" DefaultInsertValue=""
                HeaderText="Details" SortExpression="Details" UniqueName="Details">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Place" DefaultInsertValue=""
                HeaderText="Place" SortExpression="Place" UniqueName="Place">
            </telerik:GridBoundColumn>
            <telerik:GridClientDeleteColumn ConfirmText="Are you sure you want to delete this Memeber?"
                            HeaderStyle-Width="35px" ButtonType="ImageButton" ImageUrl="Delete.gif" />
        </Columns>
    </MasterTableView>
    </telerik:RadGrid>
                        

    <
    asp:AccessDataSource ID="AccessDataSource1" runat="server"
                            DataFile="~/App_Data/admindb.mdb"
                            SelectCommand="SELECT [Name], [Email], [Details], [Place] FROM [Login]" >
                           
                        </asp:AccessDataSource>
  2. Adonis
    Adonis avatar
    34 posts
    Member since:
    Nov 2008

    Posted 31 Oct 2010 Link to this post

    Have you set the command property in your grid? 

    <telerik:RadGrid  id="RadGrid1" runat="server" OnDeleteCommand="Item_Deleted" >


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. dotnetrockerzzz
    dotnetrockerzzz avatar
    32 posts
    Member since:
    Aug 2010

    Posted 01 Nov 2010 Link to this post

    I would like you to read my code properly , sir . 
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Nov 2010 Link to this post

    Hello Vaibhav,

    From your code, I can see that you are using GridClientDeleteColumn for deleting record. The delete operation on the client optimizes the performance as the source data is automatically refreshed only once on the subsequent post to the server.

    Also, you need to set the DeleteCommand of the DataSource to work it properly. See the sample code:
    <telerik:RadGrid Width="1800px" AutoGenerateDeleteColumn="true" Skin="Outlook" AllowAutomaticDeletes="true"
         ID="RadGrid1" runat="server" DataSourceID="AccessDataSource1" GridLines="None">
         <MasterTableView AutoGenerateColumns="False" DataKeyNames="MemberID" DataSourceID="AccessDataSource1">
             <Columns>
                 <telerik:GridBoundColumn DataField="MemberID" DataType="System.Int32" HeaderText="MemberID"
                     ReadOnly="True" SortExpression="MemberID" UniqueName="MemberID">
                 </telerik:GridBoundColumn>
                  . . .
             </Columns>
         </MasterTableView>
     </telerik:RadGrid>
     <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/Data/ReportPrint.mdb"
         SelectCommand="SELECT * FROM [tblMember]" DeleteCommand="DELETE FROM [tblMember] WHERE MemberID=@MemberID">
     </asp:AccessDataSource>
     
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />

    Code:
    protected void Button1_Click(object sender, EventArgs e)
    {
        RadGrid1.Rebind();
    }



    -Shinu.
Back to Top