3

gridviewをRadGridに移行しています。いくつかの問題が発生しているRadGrid行の更新に取り組んでいます。

「インプレース」編集モードでClarifyAccountNbr、site id、QuoteID列を更新しています。更新する前に、列の値が200、300、400であるとしましょう。アカウント番号、サイトID、見積もりIDを明確にします。編集ボタンをクリックして値を111、222、333に変更すると、コードをデバッグしてtextbox.text値を表示しようとすると、新しい値(111)ではなく古い値(200、300、400)が表示されます。 、222、333)。(皆さんが私の問題を理解していることを願っています)。私が間違っているところ。私を助けてください。

私はこのリンクを見ましたが、役に立たなかった。

http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-vs-gridview.aspx

あなたが見るならば、以下のコードで

string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;
string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;
string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;

デバッグしてClarifyAccountNbr、SiteID、QuoteIDをポイントすると、新しい値ではなく古い値が取得されます。(更新前)

これが私のコードです:

.aspx:

<telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30"
Height="550px" OnNeedDataSource="rg200_NeedDataSource" Width="100%" AllowPaging="True"
AllowSorting="True" AllowMultiRowSelection="True" EnableHeaderContextMenu="True"
GridLines="None" EnableHeaderContextFilterMenu="True" AllowMultiRowEdit="True"
AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" OnItemCreated="rg200_ItemCreated"
EnableViewState="False" OnUpdateCommand="rg200_UpdateCommand">
    <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White"
        HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" />
    <ExportSettings IgnorePaging="true" ExportOnlyData="true">
        <Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin=""
            PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin=""
            PageWidth="14in" />
    </ExportSettings>
    <MasterTableView GridLines="None" DataKeyNames="orderId" CommandItemDisplay="Top"
        EditMode="InPlace">
        <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
            ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
        <Columns>
            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%"
                ItemStyle-Width="3%">
                <HeaderStyle Width="3%"></HeaderStyle>
                <ItemStyle Width="3%"></ItemStyle>
            </telerik:GridClientSelectColumn>
            <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Site Name" HeaderText="Site Name" DataField="Site Name"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status"
                ReadOnly="true">
            </telerik:GridBoundColumn>
            <%--<telerik:GridTemplateColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
                DataField="Clarify Account Nbr">
                <ItemTemplate>
                    <asp:Label ID="lblClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>' runat="server"></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>'
                        runat="server"></asp:TextBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>--%>
            <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
                DataField="Clarify Account Nbr">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?">
            </telerik:GridCheckBoxColumn>
            <telerik:GridEditCommandColumn UniqueName="ECC200">
            </telerik:GridEditCommandColumn>
        </Columns>
        <PagerStyle AlwaysVisible="True"></PagerStyle>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="true" ReorderColumnsOnClient="false" AllowDragToGroup="false"
        AllowColumnsReorder="True">
        <Scrolling AllowScroll="true" EnableVirtualScrollPaging="false" UseStaticHeaders="true" />
        <Selecting AllowRowSelect="True"></Selecting>
        <Resizing AllowRowResize="true" AllowColumnResize="True" EnableRealTimeResize="True"
            ResizeGridOnColumnResize="False"></Resizing>
        <%--<ClientEvents OnGridCreated="GridCreated" OnCommand="GridCommand" />--%>
    </ClientSettings>
    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
</telerik:RadGrid>

.csファイル:

public partial class Tak200 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                Session["SearchRes"] = null;
                if (Session["TaskName"] != null)
                    lblTskName.Text = Session["TaskName"].ToString();
                Session["FilColms"] = null;
                Session["SortExp"] = null;
                Session["FilExp"] = null;
                Session["ViewAll"] = null;
                BindGrid();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    private void BindGrid()
    {
        try
        {
            DataSet dsResult = new DataSet();

            clsSearch_BL clsObj = new clsSearch_BL();
            clsObj.TaskID = (string)Session["TaskID"];
            clsObj.CustName = (string)Session["CustName"];
            clsObj.MarketName = (string)Session["MarketName"];
            clsObj.HeadendName = (string)Session["HeadendName"];
            clsObj.SiteName = (string)Session["SiteName"];
            clsObj.TaskStatus = (string)Session["TaskStatus"];
            clsObj.OrdType = (string)Session["OrdType"];
            clsObj.OrdStatus = (string)Session["OrdStatus"];
            clsObj.ProName = (string)Session["ProName"];
            clsObj.LOC = (string)Session["LOC"];
            clsObj.QuoteID = (string)Session["QuoteID"];
            clsObj.CMNumber = (string)Session["CMNumber"];

            if (Session["SearchRes"] == null)
            {
                dsResult = clsObj.getSearchResults_BL(clsObj);
                Session["SearchRes"] = dsResult;
            }
            else
                dsResult = (DataSet)Session["SearchRes"];

            DataView dataView = dsResult.Tables[0].DefaultView;
            rg200.DataSource = dsResult;
            //rg200.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    protected void rg200_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        BindGrid();
    }

    protected void rg200_PreRender(object sender, EventArgs e)
    {
        rg200.MasterTableView.GetColumnSafe("RowIndicator").Display = false;

    }

    protected void rg200_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridPagerItem)
        {
            RadComboBox combo = (e.Item as GridPagerItem).FindControl("PageSizeComboBox") as RadComboBox;

            // The number of items shown when all is selected 
            int allRowsCount = int.MaxValue;

            // Remove duplicates 
            RadComboBoxItem duplicate = combo.Items.FindItemByValue(allRowsCount.ToString());
            if (duplicate != null)
            {
                duplicate.Remove();
            }

            // Create a new item for showing all 
            RadComboBoxItem item = new RadComboBoxItem("All", allRowsCount.ToString());
            item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
            combo.Items.Add(item);

            // Set the current pagesize as the selected value 
            combo.Items.FindItemByValue(rg200.PageSize.ToString()).Selected = true;
        }
    }

    protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        int intTskID = Convert.ToInt16(Session["TaskID"]);


        GridEditableItem editedItem = e.Item as GridEditableItem;
        //Get the primary key value using the DataKeyValue.      
        string Id = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString();
        //Access the textbox from the edit form template and store the values in string variables.
        string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;
        string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;
        string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;
4

1 に答える 1

0

防弾アプローチは、この Telerik デモで示されているように、列エディターから新しいデータを取得することです。

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/editmodes/defaultcs.aspx

お役に立てれば。

ディック

于 2010-07-02T13:48:32.270 に答える