简体   繁体   English

未处理的 GridView 触发事件 RowEditing

[英]The GridView fired event RowEditing which wasn't handled

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);
            }
        }
    }

}

Above is my code behind以上是我背后的代码

Below is my.aspx page下面是 my.aspx 页面

<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>

Above is my GridView code, I have about 8 other columns too but I removed them.以上是我的 GridView 代码,我还有大约 8 个其他列,但我删除了它们。

Even though I have the row Editing method to catch any edits, my page keeps on throwing the error:即使我有行编辑方法来捕获任何编辑,我的页面仍然会抛出错误:

The GridView 'gvBuildList' fired event RowEditing which wasn't handled. GridView 'gvBuildList' 触发了未处理的事件 RowEditing。

Description:描述:

An unhandled exception occurred during the execution of the current web request.执行当前 Web 请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details:异常详细信息:

System.Web.HttpException: The GridView 'gvBuildList' fired event RowEditing which wasn't handled. System.Web.HttpException:GridView 'gvBuildList' 触发了未处理的事件 RowEditing。

Source Error:来源错误:

An unhandled exception was generated during the execution of the current web request.在执行当前 Web 请求期间生成了未处理的异常。 Information regarding the origin and location of the exception can be identified using the exception stack trace below.可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

Stack Trace:堆栈跟踪:

HttpException (0x80004005): The GridView 'gvBuildList' fired event RowEditing which wasn't handled. HttpException (0x80004005):GridView 'gvBuildList' 触发了未处理的事件 RowEditing。
System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs e) +1588857 System.Web.UI.WebControls.GridView.HandleEdit(Int32 rowIndex) +43 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.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +611
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +205 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.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9643314 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+9643314 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)+1724

Any ideas?有任何想法吗?

You can fix it by adding an empty event您可以通过添加一个空事件来修复它

protected void grd_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}

Just change the "CommandName" property of the "Edit" or "Delete" button from "Edit" to "Editttt" "Delete" to "Deleteee" (or something else which is relevent to you but make sure it is not "Edit" or "Delete").只需将“编辑”或“删除”按钮的“CommandName”属性从“编辑”更改为“Editttt”,将“删除”更改为“Deleteee”(或与您相关的其他内容,但确保它不是“编辑”或“删除”)。 It will works fine.它会工作正常。

From your gridview Code remove this从您的 gridview 代码中删除此

AutoGenerateEditButton="True"

This is not required.as you have taken the Custom Template in creating your gridview.I guess the gridview is more simple than what you have done.这不是必需的。因为您在创建 gridview 时使用了自定义模板。我猜 gridview 比您所做的更简单。

<asp:GridView ID="gvBuildList" runat="server" AutoGenerateColumns="False" AllowPaging="True" OnRowEditing="gvBuildList_RowEditing">
                                        <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
                                        <Columns>
 <asp:BoundField DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName" />
 <asp:BoundField DataField="Platform" HeaderText="Platform" SortExpression="Platform" />
 <asp:BoundField DataField="BuildDate" HeaderText="Build Date" SortExpression="BuildDate" />
 <asp:BoundField DataField="Publisher" HeaderText="Publisher" SortExpression="Publisher" />
 <asp:BoundField DataField="VersionNumber" HeaderText="Version #" SortExpression="VersionNumber" />
 <asp:BoundField DataField="FileName" HeaderText="Build" SortExpression="FileName" />
 <asp:BoundField DataField="ReleaseFileName" HeaderText="Release Notes" SortExpression="ReleaseFileName" />
 <asp:BoundField DataField="Comments" HeaderText="Comments" SortExpression="Comments" />

 <asp:ButtonField ButtonType="Image" CommandName="Edit" HeaderText="Edit"
                                                ImageUrl="Images/hard-drive-download.png" ShowHeader="True" Text="Edit" />

If you want to use Custom Template in gridview then you have to Use Command Name property.如果你想在 gridview 中使用自定义模板,那么你必须使用命令名称属性。 as Gridview will not find the Edit event.因为 Gridview 不会找到编辑事件。

Replace your gridview with this one and your code will work.用这个替换您的 gridview,您的代码将起作用。

ReBuild you application [Compile your code] and your error will be no more.重建您的应用程序 [编译您的代码],您的错误将不再存在。

As you have written code in Code behind but not compiled.因为您已经在代码隐藏中编写了代码但未编译。 so gridview is not getting the Row_editing event.所以 gridview 没有得到 Row_editing 事件。

Goto -> Build -> Rebuild Solution转到 -> 构建 -> 重建解决方案

So, after trying out a few different things, the simplest solution.所以,在尝试了一些不同的东西之后,最简单的解决方案。

I had my gridview binding in pageload.我在页面加载中绑定了 gridview。 That was what was causing this issue.这就是导致此问题的原因。 All I had to do was move the GV binding to我所要做的就是将 GV 绑定移动到

    if (!Page.IsPostBack)
    {
        getBuildData();
    }

Within the Page_Load Method在 Page_Load 方法中

Today, I also faced this problem.今天,我也遇到了这个问题。 After one hour, I noticed that there are two events in Gridview events tab.一小时后,我注意到 Gridview 事件选项卡中有两个事件。 Events names should be noted:事件名称需要注意:

  1. RowUpdating Event行更新事件

  2. RowUpdate Event行更新事件

Make sure you are using right event for your code.确保您为代码使用正确的事件。

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);
            }
        }
    }

}

Above is my code behind以上是我背后的代码

Below is my .aspx page下面是我的 .aspx 页面

<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>

Above is my GridView code, I have about 8 other columns too but I removed them.以上是我的 GridView 代码,我还有大约 8 个其他列,但我删除了它们。

Even though I have the row Editing method to catch any edits, my page keeps on throwing the error:即使我有行编辑方法来捕捉任何编辑,我的页面仍然抛出错误:

The GridView 'gvBuildList' fired event RowEditing which wasn't handled. GridView 'gvBuildList' 触发了未处理的事件 RowEditing。

Description:描述:

An unhandled exception occurred during the execution of the current web request.执行当前 Web 请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details:异常详情:

System.Web.HttpException: The GridView 'gvBuildList' fired event RowEditing which wasn't handled. System.Web.HttpException: GridView 'gvBuildList' 触发了未处理的事件 RowEditing。

Source Error:源错误:

An unhandled exception was generated during the execution of the current web request.执行当前 Web 请求期间生成了未处理的异常。 Information regarding the origin and location of the exception can be identified using the exception stack trace below.可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

Stack Trace:堆栈跟踪:

HttpException (0x80004005): The GridView 'gvBuildList' fired event RowEditing which wasn't handled. HttpException (0x80004005): GridView 'gvBuildList' 触发了未处理的事件 RowEditing。
System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs e) +1588857 System.Web.UI.WebControls.GridView.HandleEdit(Int32 rowIndex) +43 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.HandleEvent(EventArgs e, Boolean causeValidation, String validationGroup) +611
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +205 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.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9643314 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9643314 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

Any ideas?有任何想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 搜索特定行时未处理的GridView触发事件RowEditing - The GridView fired event RowEditing which wasn't handled when search for specific row GridView的“网格”触发了未处理的事件PageIndexChanging - The GridView 'grid' fired event PageIndexChanging which wasn't handled GridView的'OrdersGridView'触发了未处理的事件RowDeleting - The GridView 'OrdersGridView' fired event RowDeleting which wasn't handled GridView 触发了未处理的事件 PageIndexChanging - The GridView fired event PageIndexChanging which wasn't handled GridView&#39;GridView1&#39;触发了未处理的事件RowDeleting,但是有一个事件 - The GridView 'GridView1' fired event RowDeleting which wasn't handled , but there is an event 错误GridView'GridView1'触发了未处理的事件排序 - error The GridView 'GridView1' fired event Sorting which wasn't handled 搜索后排序-gridview1触发了未处理的事件排序 - Sorting after search - gridview1 fired event Sorting which wasn't handled GridView&#39;&#39;触发了未处理的事件RowUpdating。 ASP.NET背后的C#代码 - The GridView ' ' fired event RowUpdating which wasn't handled. C# code behind asp.net FormView触发了未处理的事件ModeChanging。 - The FormView fired event ModeChanging which wasn't handled. C#=未处理的ListView引发事件。 - C# = The ListView raised event which wasn't handled.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM