This is a migrated thread and some comments may be shown as answers.
Unable To Delete In RadGrid . Binding By Ms-access
3 Answers 45 Views
This is a migrated thread and some comments may be shown as answers.
dotnetrockerzzz
Top achievements
Rank 2
dotnetrockerzzz asked on 31 Oct 2010, 09:00 AM
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>

3 Answers, 1 is accepted

Sort by
0
Adonis
Top achievements
Rank 1
answered on 31 Oct 2010, 12:20 PM
Have you set the command property in your grid? 

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


0
dotnetrockerzzz
Top achievements
Rank 2
answered on 01 Nov 2010, 10:06 AM
I would like you to read my code properly , sir . 
0
Accepted
Shinu
Top achievements
Rank 1
answered on 02 Nov 2010, 06:36 AM
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.
Tags
Grid
Asked by
dotnetrockerzzz
Top achievements
Rank 2
Answers by
Adonis
Top achievements
Rank 1
dotnetrockerzzz
Top achievements
Rank 2
Shinu
Top achievements
Rank 1
Share this question
or