none
GridView在UpdatePanel 中无法实现页面无刷新更新 RRS feed

  • 问题

  • 大家好,问题如题示,点表格行中的更新按钮没反映,哪位大大指点一下,thks.

    <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="UpdatingAndDeleting.aspx.cs" Inherits="BinaryData_UpdatingAndDeleting" Title="Untitled Page" %>
    
        
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
     <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
      <h2>
        Add a Category with a Picture and Brochure</h2>
      <p>
       
      </p>
      <p>
        <asp:DetailsView ID="NewCategory" runat="server" AutoGenerateRows="False" DataKeyNames="CategoryID"
          DataSourceID="CategoriesDataSource" DefaultMode="Insert" OnItemInserting="NewCategory_ItemInserting" OnItemInserted="NewCategory_ItemInserted">
          <Fields>
            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
              ReadOnly="True" SortExpression="CategoryID" />
            <asp:BoundField DataField="CategoryName" HeaderText="Category" SortExpression="CategoryName" />
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
            <asp:TemplateField HeaderText="Brochure" SortExpression="BrochurePath">
              <InsertItemTemplate>
                <asp:FileUpload ID="BrochureUpload" runat="server" />
              </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Picture">
              <InsertItemTemplate>
                <asp:FileUpload ID="PictureUpload" runat="server" />
              </InsertItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowInsertButton="True" />
          </Fields>
        </asp:DetailsView>
        
        </p>
        
      <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
          <asp:Label ID="UploadWarning" runat="server" CssClass="Warning" 
            EnableViewState="False" Visible="False"></asp:Label>
          <br />
          <asp:GridView ID="Categories" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="CategoryID" DataSourceID="CategoriesDataSource" 
            EnableViewState="False" Height="468px" 
            OnRowDeleted="Categories_RowDeleted" 
            OnRowDeleting="Categories_RowDeleting" 
            OnRowUpdated="Categories_RowUpdated" 
            OnRowUpdating="Categories_RowUpdating" Width="1202px">
            
            <Columns>
            
              <asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
                <ItemStyle ForeColor="#0066FF" HorizontalAlign="Center" Width="100px" />
              </asp:CommandField>
              
              <asp:BoundField DataField="CategoryName" HeaderText="Category" 
                SortExpression="CategoryName">
                <ItemStyle Width="50px" />
              </asp:BoundField>
              <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description">
                <ItemStyle Width="600px" />
              </asp:BoundField>
              <asp:TemplateField HeaderText="Brochure">
                <ItemTemplate>
                  <%# GenerateBrochureLink(Eval("BrochurePath")) %>
                </ItemTemplate>
                <EditItemTemplate>
                  <asp:RadioButtonList ID="BrochureOptions" runat="server" AutoPostBack="True" 
                    OnSelectedIndexChanged="BrochureOptions_SelectedIndexChanged" Width="210px">
                    <asp:ListItem Selected="True" Value="1">Use current brochure</asp:ListItem>
                    <asp:ListItem Value="2">Remove current brochure</asp:ListItem>
                    <asp:ListItem Value="3">Upload new brochure</asp:ListItem>
                  </asp:RadioButtonList>
                  <asp:FileUpload ID="BrochureUpload0" runat="server" Visible="False" />
                </EditItemTemplate>
                <ItemStyle Width="210px" />
              </asp:TemplateField>
              <asp:TemplateField>
                <EditItemTemplate>
                  <span style="font-size: 10pt; width:200px color: black; font-family: Verdana; mso-fareast-font-family: 'Times New Roman';
                  mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US;
                  mso-bidi-language: AR-SA">To change the categor picture, specify a new picture.
                  <br />
                  To keep the category picture the same, leave the field empty.<br />
                  <asp:FileUpload ID="PictureUpload0" runat="server" Height="16px" 
                    Width="232px" />
                  </span>
                </EditItemTemplate>
                <ItemTemplate>
                  <asp:Image ID="Image1" runat="server" BorderColor="#3366CC" BorderStyle="Solid" 
                    BorderWidth="1px" Height="50px" 
                    ImageUrl='<%# Eval("CategoryID", "DisplayCategoryPicture.aspx?CategoryID={0}") %>' 
                    Width="50px" />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="232px" />
              </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="#993333" Font-Bold="True" Font-Size="11pt" 
              Height="40px" />
          </asp:GridView>
        </ContentTemplate>
        <Triggers>
          <asp:AsyncPostBackTrigger ControlID="Categories" EventName="RowUpdated" />
        </Triggers>
      </asp:UpdatePanel>
      
      <p>
        <asp:ObjectDataSource ID="CategoriesDataSource" runat="server" OldValuesParameterFormatString="{0}"
          SelectMethod="GetCategories" TypeName="CategoriesBLL" InsertMethod="InsertWithPicture" DeleteMethod="DeleteCategory" UpdateMethod="UpdateCategory">
          <InsertParameters>
            <asp:Parameter Name="categoryName" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="brochurePath" Type="String" />
            <asp:Parameter Name="picture" Type="Object" />
          </InsertParameters>
          
          <DeleteParameters>
            <asp:Parameter Name="categoryID" Type="Int32" />
          </DeleteParameters>
          
          <UpdateParameters>
            <asp:Parameter Name="categoryName" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="brochurePath" Type="String" />
            <asp:Parameter Name="picture" Type="Object" />
            <asp:Parameter Name="categoryID" Type="Int32" />
          </UpdateParameters>
          
        </asp:ObjectDataSource>
      </p>
    </asp:Content>
    
    
    

     

    2011年7月16日 6:07

全部回复