PDA

View Full Version : Error for Update Changed data



dicklee2003
Dec 03, 2009, 3:03 PM
Hi,

I've problem update changed data from the gridpanel. The following is the source







//ASPX for Store and GridPanel



<ext:Store ID="Store1" runat="server" OnBeforeStoreChanged="Store1_BeforeStoreChanged" UseIdConfirmation="true">


<Reader>


<ext:JsonReader ReaderID="ID">


<Fields>


<ext:RecordField Name="ID" />


<ext:RecordField Name="BIZ_NAME" />


</Fields>


</ext:JsonReader>


</Reader>


</ext:Store>


<ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true" StoreID="Store1">


<TopBar>


<ext:Toolbar runat="server" ID="ctl39">


<Items>


<ext:ToolbarButton ID="btnAdd" runat="server" Icon="Add" Text="Add">


<Listeners>


<Click Handler="var rowIndex = #{GridPanel1}.addRecord(); #{GridPanel1}.getView().focusRow(rowIndex); #{GridPanel1}.startEditing(rowIndex, 0);" />


</Listeners>


</ext:ToolbarButton>


<ext:ToolbarButton ID="btnSave" runat="server" Icon="Disk" Text="Save">


<Listeners>


<Click Handler="#{GridPanel1}.save();" />


</Listeners>


</ext:ToolbarButton>


</Items>


</ext:Toolbar>


</TopBar>


<ColumnModel ID="ColumnModel1" runat="server">


<Columns>


<ext:Column DataIndex="ID" Header="ID" ColumnID="ID">


</ext:Column>


<ext:Column DataIndex="BIZ_NAME" Header="Biz Name" ColumnID="BIZ_NAME">


<Editor>


<ext:TextField ID="txtBizName" runat="server" />


</Editor>


</ext:Column>


</Columns>


</ColumnModel>


<SelectionModel>


<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />


</SelectionModel>


</ext:GridPanel>




//CS Code behind

public partial class BizList : System.Web.UI.Page


{


BizDataSet.BIZDataTable dtBiz = new BizDataSet.BIZDataTable();


BIZTableAdapter adapterBiz = new BIZTableAdapter();


protected void Page_Load(object sender, EventArgs e)


{


if (!Ext.IsAjaxRequest)


{


Bind();


}


}





private void Bind()


{


try


{


adapterBiz.Fill(dtBiz);


Store1.DataSource = dtBiz;


Store1.DataBind();


}


catch (Exception ex)


{


string error = ex.Message;


}


}





protected void Store1_BeforeStoreChanged(object sender, Coolite.Ext.Web.BeforeStoreChangedEventArgs e)


{


Coolite.Ext.Web.ConfirmationList confirmationList = new Coolite.Ext.Web.ConfirmationList();


confirmationList = e.DataHandler.BuildConfirmationList("ID");


string json = e.DataHandler.JsonData;


StoreDataHandler dataHandler = new StoreDataHandler(json);


ChangeRecords<BizDataSet.BIZDataTable> data = dataHandler.ObjectData<BizDataSet.BIZDataTable>();


foreach (BizDataSet.BIZDataTable biz in data.Updated)


{


adapterBiz.Update(biz); //CANNOT UPDATED CHANGED DATA HERE!!!


}


foreach (BizDataSet.BIZDataTable biz in data.Created)


{


adapterBiz.Insert("");


}


}