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

Delete command issue

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 30 Dec 2011, 06:31 PM
So I have a rad grid where I delete a file using the delete command. It works fine on my test site but when I put it up on our live server and click delete, I just get an object reference not set error. I can't figure out why and have even commented out enough of my code as I was just trying to write the file name being passed in. Do you have any idea why this would work fine on the test site, but then break on the live site? I can provide a full site backup if you want, but here is the relevant code.

asp
<telerik:RadGrid ID="drawingsGrid" runat="server" AllowPaging="True" GridLines="None"
                        DataSourceID="drawingsSqlDataSource" AutoGenerateColumns="False"
                    Skin="Telerik">
                        <MasterTableView DataKeyNames="drawingId,productId,pathToPDF"
                            AllowAutomaticDeletes="True" DataSourceID="drawingsSqlDataSource">
                            <RowIndicatorColumn
                                Visible="False">
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn
                                Visible="False" Resizable="False">
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name">
                                    <HeaderStyle ForeColor="#336600"
                                        Height="23px" Width="200px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this drawing? "
                                    CommandName="Delete"
                                    Text="Delete" UniqueName="columnDelete">
                                    <HeaderStyle ForeColor="White"
                                        Height="23px" Width="50px" />
                                    <ItemStyle BorderWidth="1px" />
                                </telerik:GridButtonColumn>
                            </Columns>
                            <EditFormSettings>
                                <PopUpSettings ScrollBars="None" Width="200px" Height="200px"/>
                            </EditFormSettings>
                        </MasterTableView>
                        <HeaderStyle ForeColor="#336600" />
                    </telerik:RadGrid>



Edit* I should mention that I have verified the sp getDrawing is returning the same items on my dev site as the live site and those files do exist.



vb
Sub On_Record_Deleted(ByVal source As Object, ByVal e As SqlDataSourceStatusEventArgs)
      If (e.AffectedRows > 0) Then
 
          Response.Write(pdfFileToDelete)
 
          'If Not String.IsNullOrEmpty(pdfFileToDelete) Then
          '    Try
          '        File.Delete(Server.MapPath(pdfFileToDelete))
          '    Catch ex As Exception
          '        msgLabel.Text = ex.ToString
 
          '    End Try
          'End If
      End If
  End Sub

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 03 Jan 2012, 05:18 PM
Hello,

Could you please the same datasource and event handler with an asp:GridView and let me know if the error persists?

I am looking forward to your reply.

Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Web Services
Top achievements
Rank 2
answered on 04 Jan 2012, 08:06 PM
I'm not 100% sure if I did this right, but when I click delete in the grid view, I get this error.

Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: value


Here's my asp
<asp:GridView ID="newDrawingsGrid" runat="server" GridLines="None" DataSourceID="drawingsSqlDataSource"
                    AutoGenerateColumns="false" DataKeyNames="drawingId,productId,pathToPDF">
                    <Columns>
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">
                            <HeaderStyle ForeColor="#336600" Height="23px" Width="200px" />
                        </asp:BoundField>
                        <asp:ButtonField CommandName="Delete" Text="Delete">
                            <HeaderStyle ForeColor="White"
                                        Height="23px" Width="50px" />
                                    <ItemStyle BorderWidth="1px" />
                        </asp:ButtonField>
                    </Columns>
                    </asp:GridView>

and vb

Private Sub newDrawingsGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles newDrawingsGrid.RowCommand
    Response.Write("test")
End Sub




0
Mira
Telerik team
answered on 09 Jan 2012, 01:01 PM
Hello,

Since the problem can be replicated without the RadGrid, I assume that it is in the datasource and therefore is out of our scope.

Do not hesitate to contact us if any issue related to the RadControls for ASP.NET AJAX arise.

Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Web Services
Top achievements
Rank 2
Answers by
Mira
Telerik team
Web Services
Top achievements
Rank 2
Share this question
or