Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems updating records in mmDataView with Paging
Message
De
27/06/2007 19:04:57
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Problems updating records in mmDataView with Paging
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01236167
Message ID:
01236167
Vues:
47
Hi,

I'm having a problem updating an mmDataView grid that has paging turned on. The paging works fine but when I try to update a row that is on page 2, 3, 4, etc..., it actually ends up updating a row that is on the first page of the grid but at the same row in the page. So if i updated row 4 on page 3 it would update the data in row 4 on page 1.

Has anyone else seen this behavior?

Here some of the code

ASPX
<mm:mmGridView ID="grdSurveys" runat="server" AccessLevel="Full" AutoGenerateColumns="False" 
    BackColor="White" BindingSource="Survey" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
    CellPadding="3" ControlID="00000000-0000-0000-0000-000000000000" GridLines="Vertical" 
    IsPostBack="False" OnRowCancelingEdit="grdSurveys_RowCancelingEdit" OnRowDeleting="grdSurveys_RowDeleting" 
    OnRowEditing="grdSurveys_RowEditing" OnRowUpdating="grdSurveys_RowUpdating" SecuritySetup="True" 
    AllowPaging="True" OnPageIndexChanging="grdSurveys_PageIndexChanging" DataKeyNames="survey_id" BindingSourceMember="" UserFieldName="">
        <Columns>
            <asp:CommandField ButtonType="Button" ShowEditButton="True" >
                <itemstyle wrap="False" />
            </asp:CommandField>
            <asp:BoundField DataField="job_id" HeaderText="JobID" >
                <controlstyle width="40px" />
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="survey_date" HeaderText="Date" DataFormatString="{0:M/d/yy}"  HtmlEncode="False" >
                <controlstyle width="65px" />
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="lot_id" HeaderText="Lot #" >
                <controlstyle width="50px" />
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="address_line1" HeaderText="Address Line1" >
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="address_line2" HeaderText="Line2" >
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="City" HeaderText="City" >
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="State" HeaderText="State" >
                <controlstyle width="30px" />
            </asp:BoundField>
            <asp:BoundField DataField="zip" HeaderText="Zip" >
                <controlstyle width="50px" />
            </asp:BoundField>
            <asp:BoundField DataField="longitude" HeaderText="Longitude" ReadOnly="True" DataFormatString="{0:#.000000}"  HtmlEncode="False" >
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:BoundField DataField="latitude" HeaderText="Latitude" ReadOnly="True" DataFormatString="{0:#.000000}"   HtmlEncode="False" >
                <itemstyle wrap="False" />
            </asp:BoundField>
            <asp:CommandField ButtonType="Button" ShowDeleteButton="True" >
                <itemstyle wrap="False" />
            </asp:CommandField>
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <AlternatingRowStyle BackColor="Gainsboro" />
        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <PagerSettings NextPageText="Next" PreviousPageText="Previous" />
    </mm:mmGridView>
And the ASPX.CS code
public partial class SurveyorAdmin_SurveyList : mmBusinessWebPage
{
    Survey oSurvey; 

    /// <summary>
    /// Page Load handler
    /// </summary>
    /// <param name="sender">Event source</param>
    /// <param name="e">Event args</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        oSurvey = (Survey)RegisterBizObj(new Survey());

        if (!IsPostBack)
        {
            oSurvey.GetSurveyorSurveys((int)Session["surveyorid"]);
            Session["dsSurveys"] = this.oSurvey.DataSet;

            lblCount.Text = this.oSurvey.DataSet.Tables[0].Rows.Count.ToString();
        }
        else
        {
            DataSet dsSurveys = (DataSet)Session["dsSurveys"];
            this.oSurvey.SetCurrentDataSet(dsSurveys);
        }
    }

    protected void grdSurveys_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        this.grdSurveys.EditIndex = -1;
        this.BindControl(this.grdSurveys);
    }

    protected void grdSurveys_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DataSet dsSurveys = (DataSet)Session["dsSurveys"];
        this.oSurvey.Delete(dsSurveys, e.RowIndex);
        this.BindControl(this.grdSurveys);
    }

    protected void grdSurveys_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.grdSurveys.EditIndex = e.NewEditIndex;
        this.BindControl(this.grdSurveys);
    }

    protected void grdSurveys_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        this.grdSurveys.EditIndex = e.RowIndex;
        DataSet dsSurveys = (DataSet)Session["dsSurveys"];
        this.Save(this.oSurvey, dsSurveys);
        this.grdSurveys.EditIndex = -1;
        this.BindControl(this.grdSurveys);
    }

    protected void grdSurveys_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdSurveys.PageIndex = e.NewPageIndex;
        grdSurveys.DataSource = Session["dsSurveys"];
        grdSurveys.DataBind();
    }
}
Govinda Berrio
GKG Inc.
Providence, RI
http://www.gkginc.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform