Das GridView-Ereignis ausgelöst RowEditing, die nicht behandelt

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AppManagementConsole
{
    public partial class _Default : Page
    {
        string BuildUploadPath = ConfigurationManager.AppSettings["DirectoryPath"] + "Files/";
        string ReleaseNotesUpPath = ConfigurationManager.AppSettings["DirectoryPath"] + "ReleaseNotes/";

    protected void Page_Load(object sender, EventArgs e)
    {
        cpBuildDate.SelectedDate = DateTime.Now;
        getBuildData();
    }

    public void getBuildData()
    {
        //Select Build List
        SqlCommand selectCommand = new SqlCommand("Select * from tblBuildList");

        try
        {
            //Connect to DB
            using (SqlConnection conRDB = new SqlConnection(ConfigurationManager.ConnectionStrings["conRDB"].ConnectionString))
            {
                SqlDataAdapter selectAdapater = new SqlDataAdapter(selectCommand.CommandText, conRDB);

                DataSet dsBuilds = new DataSet();
                selectAdapater.Fill(dsBuilds);

                //Populate Webpage GV
                gvDataBind(dsBuilds);
            }
        }

        catch (Exception ex)
        {
        }
    }


    public void gvDataBind(DataSet dsBuilds)
    {
        gvBuildList.Dispose();
        gvBuildList.DataSource = dsBuilds;
        gvBuildList.DataBind();
    }

    protected void gvBuildList_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gvBuildList.PageIndex = e.NewEditIndex;
        //Bind data to the GridView control.
        getBuildData();
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //Upload Files
        UploadFiles();

        //Update SQL Table
        AddBuildInfo(txtProduct.Text, txtPlatform.Text, cpBuildDate.SelectedDate, txtPublisher.Text, txtVersion.Text, BuildUploadPath,FileUpBuild.FileName, ReleaseNotesUpPath, FileUpRelease.FileName, txtComments.Text);
    }

    private void UploadFiles()
    {
        #region Build
        string tempfileDir = @"C:\Publish\TempFileStorage\";
        if (FileUpBuild.HasFile)
        {
            try
            {
                if (!Directory.Exists(tempfileDir))
                {
                    Directory.CreateDirectory(tempfileDir);
                }
                FileUpBuild.SaveAs(@"C:\Publish\TempFileStorage\" + FileUpBuild.FileName);
                FTP.FtpUpload(BuildUploadPath, FileUpBuild.FileName, tempfileDir + FileUpBuild.FileName);
                //FileUpBuild.SaveAs();
                //FileUpBuild.FileContent();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                File.Delete(@"C:\Publish\TempFileStorage\" + FileUpBuild.FileName);
            }
        }
        #endregion

        #region ReleaseNotes
        if (FileUpRelease.HasFile)
        {
            try
            {
                if (!Directory.Exists(tempfileDir))
                {
                    Directory.CreateDirectory(tempfileDir);
                }
                FileUpRelease.SaveAs(@"C:\Publish\TempFileStorage\" + FileUpRelease.FileName);
                FTP.FtpUpload( ReleaseNotesUpPath, FileUpRelease.FileName, tempfileDir + FileUpRelease.FileName);
                //FileUpBuild.SaveAs();
                //FileUpBuild.FileContent();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                File.Delete(@"C:\Publish\TempFileStorage\" + FileUpRelease.FileName);
            }
        }
        #endregion

    }

    private void AddBuildInfo(string product, string platform, DateTime builddate, string publisher, string version, string location, string filename, string releaseloc, string releasefile, string comment)
    {
        try
        {
            using (SqlConnection conRDB = new SqlConnection(ConfigurationManager.ConnectionStrings["conRDB"].ConnectionString))
            {
                SqlCommand insertCommand = new SqlCommand("Insert into tblBuildList " +
                                                "Values('" + product + "'," +
                                                        "'" + platform + "'," +
                                                        "'" + builddate + "'," +
                                                        "'" + publisher + "'," +
                                                        "'" + version + "'," +
                                                        "'" + location + "'," +
                                                        "'" + filename + "'," +
                                                        "'" + releaseloc + "'," +
                                                        "'" + releasefile + "'," +
                                                        "'" + comment + "')", conRDB);
                conRDB.Open();
                insertCommand.ExecuteNonQuery();

                getBuildData();
                conRDB.Close();
            }
        }

        catch (Exception ex)
        {
        }
    }

    protected void btnUpBuild_Click(object sender, EventArgs e)
    {
        string tempfileDir = @"C:\Publish\TempFileStorage\";
        if (FileUpBuild.HasFile)
        {
            try
            {
                if (!Directory.Exists(tempfileDir))
                {
                    Directory.CreateDirectory(tempfileDir);
                }
                FileUpBuild.SaveAs(@"C:\Publish\TempFileStorage\" + FileUpBuild.FileName);
                FTP.FtpUpload(BuildUploadPath, FileUpBuild.FileName, tempfileDir + FileUpBuild.FileName);
                //FileUpBuild.SaveAs();
                //FileUpBuild.FileContent();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                File.Delete(@"C:\Publish\TempFileStorage\" + FileUpBuild.FileName);
            }
        }
    }

    protected void btnUpRelease_Click(object sender, EventArgs e)
    {
        string tempfileDir = @"C:\Publish\TempFileStorage\";
        if (FileUpRelease.HasFile)
        {
            try
            {
                if (!Directory.Exists(tempfileDir))
                {
                    Directory.CreateDirectory(tempfileDir);
                }
                FileUpRelease.SaveAs(@"C:\Publish\TempFileStorage\" + FileUpRelease.FileName);
                FTP.FtpUpload( ReleaseNotesUpPath, FileUpRelease.FileName, tempfileDir + FileUpRelease.FileName);
                //FileUpBuild.SaveAs();
                //FileUpBuild.FileContent();
            }
            catch (Exception ex)
            {
            }
            finally
            {
                File.Delete(@"C:\Publish\TempFileStorage\" + FileUpRelease.FileName);
            }
        }
    }

}

Oben ist mein code hinter

Unten ist meine .aspx-Seite

<div id="Addnewbuild">
    <h3>Add a New Build</h3>
    <table>
        <tr>
            <th>
                <asp:Label ID="lblHeader1" runat="server">Product</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader2" runat="server">Platform</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader3" runat="server">Build Date</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader31" runat="server">Publisher</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader4" runat="server">Version #</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader5" runat="server">Build</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader6" runat="server">Release Notes</asp:Label>
            </th>
            <th>
                <asp:Label ID="lblHeader7" runat="server">Comments</asp:Label>
            </th>
        </tr>
        <tr>
            <td>
                <asp:TextBox ID="txtProduct" runat="server" Width="150px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="txtPlatform" runat="server" Width="75px"></asp:TextBox>
            </td>
            <td>
                <ew:CalendarPopup ID="cpBuildDate" ControlDisplay="TextBoxButton" Text="Change Date"
                    runat="server" SelectedDate="" VisibleDate="" Visible="True" Enabled="True" Width="100px">
                </ew:CalendarPopup>
            </td>
            <td>
                <asp:TextBox ID="txtPublisher" runat="server" Width="75px"></asp:TextBox>
            </td>
            <td>
                <asp:TextBox ID="txtVersion" runat="server" Width="75px"></asp:TextBox>
            </td>
            <td>
                <asp:FileUpload ID="FileUpBuild" runat="server" />
                <!--<asp:Button ID="btnUpBuild" runat="server" Text="Upload Build" OnClick="btnUpBuild_Click" />-->
            </td>
            <td>
                <asp:FileUpload ID="FileUpRelease" runat="server" />
                <!--<asp:Button ID="btnUpRelease" runat="server" Text="Upload Release Notes" OnClick="btnUpRelease_Click" />-->
            </td>
            <td>
                <asp:TextBox ID="txtComments" runat="server" Width="100px" TextMode="MultiLine"></asp:TextBox>
            </td>
        </tr>
    </table>

    <asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
</div>
<br />
<br />
<br />

<div id="buildlist">
    <h3>Build List</h3>
            <asp:GridView ID="gvBuildList" runat="server" AutoGenerateColumns="False" AllowPaging="True" OnRowEditing="gvBuildList_RowEditing" AutoGenerateEditButton="True">
                <Columns>
                    <asp:TemplateField HeaderText="Product">
                        <ItemTemplate>
                            <asp:Label ID="lblProduct" runat="server" Text='<%#Eval("ProductName")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVProduct" runat="server" Text='<%#Eval("ProductName")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Platform">
                        <ItemTemplate>
                            <asp:Label ID="lblplatform" runat="server" Text='<%#Eval("Platform")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVPlatform" runat="server" Text='<%#Eval("Platform")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Build Date">
                        <ItemTemplate>
                            <asp:Label ID="lblbldDate" runat="server" Text='<%#Eval("BuildDate")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVbldDate" runat="server" Text='<%#Eval("BuildDate")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Publisher">
                        <ItemTemplate>
                            <asp:Label ID="lblPublisher" runat="server" Text='<%#Eval("Publisher")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVPublisher" runat="server" Text='<%#Eval("Publisher")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Version #">
                        <ItemTemplate>
                            <asp:Label ID="lblVersion" runat="server" Text='<%#Eval("VersionNumber")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVVersion" runat="server" Text='<%#Eval("VersionNumber")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Build">
                        <ItemTemplate>
                            <asp:Label ID="lblbldLocation" runat="server" Text='<%#Eval("FileName")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVbldLocation" runat="server" Text='<%#Eval("FileName")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Release Notes">
                        <ItemTemplate>
                            <asp:Label ID="lblRelease" runat="server" Text='<%#Eval("ReleaseFileName")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVRelease" runat="server" Text='<%#Eval("ReleaseFileName")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Comments">
                        <ItemTemplate>
                            <asp:Label ID="lblComments" runat="server" Text='<%#Eval("Comments")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtGVComments" runat="server" Text='<%#Eval("Comments")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="True" ButtonType="Button" />
                    <asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
                    <asp:TemplateField HeaderText="Actions">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDwnld" runat="server" ImageURL="Images/hard-drive-download.png" Width="20" Height="20" />
                            <asp:ImageButton ID="btnEmail" runat="server" ImageURL="Images/email-icon.png" Width="20" Height="20" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
</div>

Oben ist mein GridView-code, ich habe ungefähr 8 anderen Spalten auch, aber ich entfernte Sie.

Obwohl ich die Zeile Bearbeiten-Methode zu fangen alle Bearbeitungen, meine Seite hält, werfen Sie den Fehler:

GridView 'gvBuildList" gefeuert Veranstaltung RowEditing, die nicht behandelt werden.

Beschreibung:

Eine nicht behandelte Ausnahme ist aufgetreten während der Ausführung der aktuellen
web-Anfrage. Bitte überprüfen Sie die Stapelüberwachung für weitere Informationen über
die Fehler und wo Sie Ihren Ursprung in den code.

Ausnahmedetails:

System.Web.HttpException: Das GridView - 'gvBuildList' - Ereignis ausgelöst
RowEditing, die nicht behandelt werden.

Quelle Fehler:

Wurde eine unbehandelte Ausnahme generiert, die während der Ausführung des
aktuellen web-Anfrage. Informationen über den Ursprung und die Lage des
die Ausnahme identifiziert werden kann mit der Ausnahmestapelüberwachung unten.

Stack Trace:

HttpException (0 x 80004005): Die GridView 'gvBuildList' - Ereignis ausgelöst
RowEditing, die nicht behandelt werden.

System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs
e) +1588857 System.Web.UI.WebControls.GridView.HandleEdit(Int32
rowIndex) +43

System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +611

System.Web.UI.WebControls.GridView.RaisePostBackEvent(String
eventArgument) +205

System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +13

System.Web.UI.Seite.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13

System.Web.UI.Seite.RaisePostBackEvent(NameValueCollection postData)
+9643314 System.Web.UI.Seite.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1724

Irgendwelche Ideen?

InformationsquelleAutor ArjaaAine | 2012-11-01

Schreibe einen Kommentar