iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
WebUI Studio 2009 R2
I have a webgrid bound to a ISDataSource (ISD). The ISD has SchemaType="CustomObject" and InsertMethod="InsertComment". That inserts into a database table called "commnts" with it's primary key as id_comment as autoincrement.The InsertComment method calls a Stored Procedure in the database that inserts a comment record and returnes the newly inserted id_comment.Now I have to somehow get that returned id_comment into the new webgrid row. So I tried setting the oninserted="ISDataSource1_Inserted" for the ISD:
protected void ISDataSource1_Inserted(object sender, ISNet.WebUI.DataSource.ISDataSourceStatusEventArgs e) {
c_webGrid.RootTable.UpdateRowIdentity("idComment", "-1", e.ReturnValue); }
I notice that "e.ReturnValue" is returning the correct newly inserted id_comment, but this call does unfortunately not update the column of the new row in the grid. I have also tried using the "DataMember" instead:
c_webGrid.RootTable.UpdateRowIdentity("id_comment", "-1", e.ReturnValue);
But that does not help either.
Where can I put in the returned auto-increment id_comment to the web grid column of the newly inserted row, after insert?If it helps the SelectMethod of the ISD returns a DataTable from the custom object, one of the columns of the DataTable is id_comment and I have tried to play with all that stuff:
var c = tbl.Columns.Add(Consts.Columns.IdComment, typeof (int)); /*c.AutoIncrement = true; c.AutoIncrementSeed = 0; c.AutoIncrementStep = 1; c.AllowDBNull = false;*/ c.Unique = true; DataColumn[] pk = new DataColumn[1]; pk[0] = c; tbl.PrimaryKey = pk;
But it did not help.
In the webgrid I specify:
<RootTable Caption="tblComments" DataKeyField="id_comment"> <Columns> <ISWebGrid:WebGridColumn Caption="ID" DataMember="id_comment" DataType="System.Int32" Name="idComment" EditType="NoEdit" IsAutoIncrement="true" Visible="true" > <HeaderStyle HorizontalAlign="Center" /> <CellStyle HorizontalAlign="Right" /> </ISWebGrid:WebGridColumn> ...
Regards
TJ
Hi TJ,
Could I look for your selecting method in ISDataSource? You must handle selection and insertion method if you have identity column in you database. This Knowledge Base maybe will help you to handle retrieving identity value:
http://www.intersoftpt.com/Support/WebGrid/KB/Retrieving-Identity-(Auto-generated-values)-during-Insert-operation-in-WebGrid-Hierarchical-Load-on-Demand-Scenario-using-ISDataSource-NET/
Hope this helps.
Regards,Bernard
Hi Bernard,I read your article. Unfortunately the attached code-sample is not accessible any more. However from that article I read that the only thing I had to do was to change the first parameter of my Insert method to be a ref-value:
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)] public object IsDsInsertComment(ref int idComment, string userId, int idPointGroup,....) { : idComment = Convert.ToInt32(cmd.ExecuteScalar()); : return idComment; }
The insert to the database works fine as before, however the new value of idComment does not appear in the WebGrid. You can se the webgrid table column defination above. Here is the ISDataSource defination:
<ISDataSource:ISDataSourceTable ConflictDetection="OverwriteChanges" ParameterOption="FromFields" SelectMethod="IsDsGetComments" UpdateMethod="IsDsUpdateComment" InsertMethod="IsDsInsertComment" DeleteMethod="IsDsDeleteComment" TableName="tblComments" TypeName="C2Net.Common.Lbo.LboComment" OldValuesParameterFormatString="original_{0}"> <SelectParameters> <asp:Parameter Name="idPointGroup" Type="Int32" DefaultValue="-1" /> <asp:Parameter Name="idBuilding" Type="Int32" DefaultValue = "-1"/> <asp:Parameter Name="idOpcGroup" Type="Int32" DefaultValue="-1" /> <asp:Parameter Name="from" Type="DateTime" /> <asp:Parameter Name="to" Type="DateTime" /> </SelectParameters> </ISDataSource:ISDataSourceTable>
Regards TJ
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname