0

我目前在 TAB 容器中有一个 asp.net 页面,该页面有一个搜索框,用于SqlDataSource在 asp.net 页面上没有附加的材料,一旦您单击搜索按钮,就会RadWindow弹出RadGrid显示详细信息。

RadGrida 中UpdatePanel,一旦在 内单击 Edit 按钮,就会RadGrid弹出编辑窗口,但是当我尝试选择RadComboBoxCurrency、Company 和 Country 等任何一项时,没有回发发生,也不会在我单击时触发回发编辑模式下的Update按钮。

内部RadComboBoxRadGrid通过使用EditItemTemplate.

请看以下代码:

ASPX代码:

 <ajaxToolkit:TabPanel runat="server" HeaderText="TabPanel7" ID="TabPanel7">
    <HeaderTemplate>Edit/Delete PO Reports</HeaderTemplate>
    <ContentTemplate>
    <br />        
    <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel4">
    <ProgressTemplate>
    <div style="background-color: Gray; filter:alpha(opacity=60); opacity:0.60; width: 100%; top: 0px; left: 0px; position: fixed; height: 100%;">
    </div>
      <div style="margin:auto;
          font-family:Trebuchet MS;
          filter: alpha(opacity=100);
          opacity: 1;
          font-size:small;
          vertical-align: middle;
          top: 45%;
          position: fixed;
          right: 45%;
          color: #275721;
          text-align: center;
          background-color: White;
          height: 100px;
          ">
            <table style=" background-color: White; font-family: Sans-Serif; text-align: center; border: solid 1px #275721; color: #275721; width: inherit; height: inherit; padding: 15px;">
            <tr>
            <td style=" text-align: inherit;"><img src="images/loadingIcon.gif" alt="Loading"  /></td>
            <td style=" text-align: inherit;"><span style="font-family: Sans-Serif; font-size: medium; font-weight: bold; font">Loading...</span></td>
            </tr>
            </table>
            </div>
         </ProgressTemplate>
      </asp:UpdateProgress>
      <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
            Enter a Saudi Aramco PO Number: 
        <telerik:RadComboBox ID="EditPORadComboBox" runat="server" 
            DataSourceID="SAPOSqlDataSource" DataTextField="SA_PO" DataValueField="SA_PO" 
                    MarkFirstMatch="True">
        </telerik:RadComboBox>
                <asp:SqlDataSource ID="SAPOSqlDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ROGContext %>" 
                    SelectCommand="SELECT [SA_PO] FROM [PODB]"></asp:SqlDataSource>          
        &nbsp; <asp:Button ID="SearchEditPOButton" runat="server" Text="Search" 
            onclick="SearchEditPOButton_Click" OnClientClick="togglePoppModality" Height="35px" Width="115px" />      
        </ContentTemplate>
        </asp:UpdatePanel>            
        <br />
        <br />                   
        <telerik:RadWindow ID="EditPORadWindow" runat="server" Width="1800px" 
            Height="1000px">
        <ContentTemplate>       
        <asp:UpdatePanel ID="UpdatePanel5" runat="server">
        <ContentTemplate>
        <telerik:RadGrid ID="EditPORadGrid" runat="server" HorizontalAlign="Center"
            CellSpacing="0" GridLines="None" AutoGenerateDeleteColumn="True"
            AutoGenerateEditColumn="True"
            OnUpdateCommand="EditPORadGrid_UpdateCommand" 
            onneeddatasource="EditPORadGrid_NeedDataSource" OnItemDataBound="EditPORadGrid_ItemDataBound" 
            AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" 
            AutoGenerateColumns="False">
        <MasterTableView CommandItemDisplay="Top" DataKeyNames="SA_PO"
            EditMode="PopUp">
            <CommandItemSettings ExportToPdfText="Export to PDF" 
                ShowAddNewRecordButton="False" ShowRefreshButton="True" />
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" 
                Visible="True">
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" 
                Visible="True">
            </ExpandCollapseColumn>
            <Columns>
            <telerik:GridBoundColumn DataField="SA_PO"
                        FilterControlAltText="Filter SA_PO column" HeaderText="SA PO" 
                        SortExpression="SA_PO" UniqueName="SA_PO" ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PO_Date"
                        FilterControlAltText="Filter PO_Date column" HeaderText="PO_Date" 
                        SortExpression="PO_Date" UniqueName="PO_Date">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Packaging_Details"
                        FilterControlAltText="Filter Packaging_Details column" 
                        HeaderText="Packaging Details" SortExpression="Packaging_Details" 
                        UniqueName="Packaging_Details">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Country_Origin" 
                        FilterControlAltText="Filter Country_Origin column" HeaderText="Country Origin" 
                        SortExpression="Country_Origin" UniqueName="Country_Origin">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Required_Document"
                        FilterControlAltText="Filter Required_Document column" 
                        HeaderText="Required Document" SortExpression="Required_Document" 
                        UniqueName="Required_Document">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Shipping_Label" 
                        FilterControlAltText="Filter Shipping_Label column" HeaderText="Shipping Label" 
                        SortExpression="Shipping_Label" UniqueName="Shipping_Label">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Special_Instruction"
                        FilterControlAltText="Filter Special_Instruction column" 
                        HeaderText="Special Instruction" SortExpression="Special_Instruction" 
                        UniqueName="Special_Instruction">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Payment_Terms"
                        FilterControlAltText="Filter Payment_Terms column" HeaderText="Payment Terms" 
                        SortExpression="Payment_Terms" UniqueName="Payment_Terms">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Mode_Shipment"
                        FilterControlAltText="Filter Mode_Shipment column" HeaderText="Mode of Shipment" 
                        SortExpression="Mode_Shipment" UniqueName="Mode_Shipment">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ExpectedDelivery_Date"
                        FilterControlAltText="Filter ExpectedDelivery_Date column" 
                        HeaderText="Expected Delivery Date" SortExpression="ExpectedDelivery_Date" 
                        UniqueName="ExpectedDelivery_Date">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Material_No" 
                        FilterControlAltText="Filter Material_No column" 
                        HeaderText="Material No" SortExpression="ExpectedDelivMaterial_Noery_Date" 
                        UniqueName="Material_No">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="QTY" 
                        FilterControlAltText="Filter QTY column" HeaderText="QTY" SortExpression="QTY" 
                        UniqueName="QTY">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Unit_Price" 
                        FilterControlAltText="Filter Unit_Price column" HeaderText="Unit Price" 
                        SortExpression="Unit_Price" UniqueName="Unit_Price">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Total_Price" 
                        FilterControlAltText="Filter Total_Price column" HeaderText="Total Price" 
                        SortExpression="Total_Price" UniqueName="Total_Price" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ROG_PO" 
                        FilterControlAltText="Filter ROG_PO column" HeaderText="ROG PO#" ReadOnly="True" 
                        SortExpression="ROG_PO" UniqueName="ROG_PO">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Product_Line"
                        FilterControlAltText="Filter Product_Line column" HeaderText="Product Line" 
                        SortExpression="Product_Line" UniqueName="Product_Line">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Profile_No"
                        FilterControlAltText="Filter Profile_No column" HeaderText="Profile No" 
                        SortExpression="Profile_No" UniqueName="Profile_No">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="IncoTerms" 
                        FilterControlAltText="Filter IncoTerms column" HeaderText="IncoTerms" 
                        SortExpression="IncoTerms" UniqueName="IncoTerms">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Material_No9COM"
                        FilterControlAltText="Filter Material_No9COM column" 
                        HeaderText="Material No.9COM" SortExpression="Material_No9COM" 
                        UniqueName="Material_No9COM">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn UniqueName="Currency" HeaderText="Currency"
                    SortExpression="Currency" FilterControlAltText="Filter Currency column" DataField="Currency" AllowFiltering="true">
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container.DataItem, "Currency")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox runat="server" ID="CurrencyRadComboBox2" EnableLoadOnDemand="true" DataTextField="Currency"
                         DataValueField="Currency" AutoPostBack="true" HighlightTemplatedItems="true" Filter="Contains" OnItemsRequested="CurrencyRadComboBox2_ItemsRequested" OnSelectedIndexChanged="CurrencyRadComboBox2_OnSelectedChangedIndex">
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Company" HeaderText="Company" SortExpression="Company" 
                    FilterControlAltText="Filter Company column" DataField="Company" AllowFiltering="true">
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container.DataItem, "Company")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox runat="server" ID="CompanyRadComboBox" EnableLoadOnDemand="true" DataTextField="Company"
                         DataValueField="Company" AutoPostBack="true" HighlightTemplatedItems="true" Filter="Contains">
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Country" HeaderText="Country" SortExpression="Country" 
                    FilterControlAltText="Filter Country column" DataField="Country" AllowFiltering="true">
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container.DataItem, "Country")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox runat="server" ID="CountryRadComboBox" EnableLoadOnDemand="true" DataTextField="Country"
                         DataValueField="Country" AutoPostBack="true" HighlightTemplatedItems="true" Filter="Contains">
                        </telerik:RadComboBox>
                    </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="Product_Description"
                        FilterControlAltText="Filter Product_Description column" 
                        HeaderText="Product Description" SortExpression="Product_Description" 
                        UniqueName="Product_Description">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Size"
                        FilterControlAltText="Filter Size column" HeaderText="Size" 
                        SortExpression="Size" UniqueName="Size">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="UOM" 
                        FilterControlAltText="Filter UOM column" HeaderText="UOM" SortExpression="UOM" 
                        UniqueName="UOM">
                    </telerik:GridBoundColumn>
            </Columns>                
            <EditFormSettings CaptionDataField="SA_PO" CaptionFormatString="Edit Saudi Aramco PO No.: {0}">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
            <PagerStyle PageSizeControlType="RadComboBox" />
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowClick="RowDblClick" />
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
        <PagerStyle PageSizeControlType="RadComboBox" />
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        </telerik:RadGrid>
        </ContentTemplate>
        </asp:UpdatePanel>
        </ContentTemplate>
        </telerik:RadWindow>
    </ContentTemplate>
    </ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>    

C#代码:

     protected void SearchEditPOButton_Click(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(2000);
        string script = "function f(){$find(\"" + EditPORadWindow.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        /*if (EditPORadComboBox.SelectedValue.ToString() != "")
        {
            string editpotxt = EditPORadComboBox.SelectedValue.ToString();
            long editpoint = Convert.ToInt64(editpotxt);

            var queryselect = from p in db.PODBs
                              where p.SA_PO == editpoint
                              select new
                              {
                                  p.SA_PO,
                                  p.PO_Date,
                                  p.Packaging_Details,
                                  p.Country_Origin,
                                  p.Required_Document,
                                  p.Shipping_Label,
                                  p.Payment_Terms,
                                  p.Mode_Shipment,
                                  p.ExpectedDelivery_Date,
                                  p.Material_No,
                                  p.QTY,
                                  p.Unit_Price,
                                  p.Total_Price,
                                  p.Product_Line,
                                  p.Profile_No,
                                  p.IncoTerms,
                                  p.Material_No9COM,
                                  p.Currency,
                                  p.Company,
                                  p.Country,
                                  p.Product_Description,
                                  p.Size,
                                  p.UOM
                              };

            EditPORadGrid.Visible = true;
            EditPORadGrid.DataSource = queryselect.ToList();
            EditPORadComboBox.DataBind();
        }*/
    }

    protected void EditPORadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (EditPORadComboBox.SelectedValue.ToString() != "")
        {
            string editpotxt = EditPORadComboBox.SelectedValue.ToString();
            long editpoint = Convert.ToInt64(editpotxt);

            var queryselect = from p in db.PODBs
                              where p.SA_PO == editpoint
                              select new
                              {
                                  p.SA_PO,
                                  p.PO_Date,
                                  p.Packaging_Details,
                                  p.Country_Origin,
                                  p.Required_Document,
                                  p.Shipping_Label,
                                  p.Payment_Terms,
                                  p.Mode_Shipment,
                                  p.ExpectedDelivery_Date,
                                  p.Material_No,
                                  p.QTY,
                                  p.Unit_Price,
                                  p.Total_Price,
                                  p.Product_Line,
                                  p.Profile_No,
                                  p.IncoTerms,
                                  p.Material_No9COM,
                                  p.Currency,
                                  p.Company,
                                  p.Country,
                                  p.Product_Description,
                                  p.Size,
                                  p.UOM
                              };

            EditPORadGrid.Visible = true;
            EditPORadGrid.DataSource = queryselect.ToList();
        }
    }

    protected void EditPORadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.IsInEditMode)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;

            var querycurrency = (from c in db.CurrencyDBs
                                 select c.Currency).ToList();

            RadComboBox currencycombo = (RadComboBox)editedItem.FindControl("CurrencyRadComboBox2");

            foreach (string currencyelement in querycurrency)
            {
                RadComboBoxItem selecteditem = new RadComboBoxItem();
                selecteditem.Text = currencyelement.ToString();
                selecteditem.Attributes.Add("Currency", currencyelement.ToString());
                currencycombo.Items.Add(selecteditem);
                selecteditem.DataBind();
            }

            var querycompany = (from x in db.SupplierDBs
                                select x.Company).ToList();

            RadComboBox companycombo = (RadComboBox)editedItem.FindControl("CompanyRadComboBox");

            foreach (string companyelement in querycompany)
            {
                RadComboBoxItem selecteditem = new RadComboBoxItem();
                selecteditem.Text = companyelement.ToString();
                selecteditem.Attributes.Add("Company", companyelement.ToString());
                companycombo.Items.Add(selecteditem);
                selecteditem.DataBind();
            }

            var querycountry = (from s in db.CountryCodes
                                select s.CountryName).ToList();

            RadComboBox countrycombo = (RadComboBox)editedItem.FindControl("CountryRadComboBox");

            foreach (string countryelement in querycountry)
            {
                RadComboBoxItem selecteditem = new RadComboBoxItem();
                selecteditem.Text = countryelement.ToString();
                selecteditem.Attributes.Add("Country", countryelement.ToString());
                countrycombo.Items.Add(selecteditem);
                selecteditem.DataBind();
            }
        }
    }

    protected void CurrencyRadComboBox2_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {

        var querycurrency = (from c in db.CurrencyDBs
                             select c.Currency).ToList();

        RadComboBox currencycombo = (RadComboBox)sender;

        foreach (string currencyelement in querycurrency)
        {
            RadComboBoxItem selecteditem = new RadComboBoxItem();
            selecteditem.Text = currencyelement.ToString();
            selecteditem.Attributes.Add("Currency", currencyelement.ToString());
            currencycombo.Items.Add(selecteditem);
            selecteditem.DataBind();
        }
    }

    protected void CurrencyRadComboBox2_OnSelectedChangedIndex(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        var querycurrency = (from c in db.CurrencyDBs
                             select c.Currency).ToList();

        RadComboBox currencycombo = (RadComboBox)sender;

        foreach (string currencyelement in querycurrency)
        {
            RadComboBoxItem selecteditem = new RadComboBoxItem();
            selecteditem.Text = currencyelement.ToString();
            selecteditem.Attributes.Add("Currency", currencyelement.ToString());
            currencycombo.Items.Add(selecteditem);
            selecteditem.DataBind();
        }
    }

    protected void EditPORadGrid_UpdateCommand(object sender, GridCommandEventArgs e)
    {
    }
4

0 回答 0