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, I am trying to programmatically add a new row to the grid on client side. At this point, I dont want to update the data source, just the grid.
Im using this code to add the row(s), but, the grid just keeps going into limbo with a "Adding new row" message:
{
newRow.Update();
}
Here is my grid definition:
can anyone help?
thanks
Hello Darren,
When you set text in new row, the text would not persist in New row object if you don't select or mark edit the new row. Note: Please try to open WebGrid sample >> Client_ProgrammaticEdit.
Also, your scenario doesn't want to update into data source. Normally, when you used newRow.Update(), it will be automatically be saved into database, except you return false at Add_row server side event.
protected void WebGrid1_AddRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { e.ReturnValue = false; }
Regards,Handy
Hi Handy,
Thanks for the advice. Im not too sure what you mean by "select or mark edit the new row"? Do you mean the user has to select something within the grid?
Ive taken a look a the Client_ProgrammaticEdit page, and it looks pretty much the same as the code I have - ie (code from Client_ProgrammaticEdit):
..........................
newRow.Update(); // insert new record
My code:
this still doesnt work for me, can you offer any more advice?
thanks again
I enclosed one simple sample (as attachment) based on your scenario description.
Could you please show us in more detail about the ‘grid just keeps going into limbo with “Adding new row” message’ issue? Any screenshot or video would be helpful.
Hi Yudi,
Ive attached an image showing what is happening in the webgrid. It never gets passed this stage.
I noticed you see the same problem in the WebGrid sample >> Client_ProgrammaticEdit (which Handy pointed me to above), when I click on "Add New Row" then clicking "insert" withouth adding any values.
Also, another piece of information. Although I dont want to update the data source when I add a row, the grid Im using IS databound (to a datatable based on sql server query results). As a test, I tried binding the grid to a data table i manually created in code, and the add row functionality worked. On binding to the sql data sourceagain, it doesnt. Ive attached the aspx page and code behind for my test page.
Darren
I enclosed a video that shows how the sent sample runs on my end. I also enclosed one full project of WebGrid (file system WebSite) as attachment that I used as the tester project.
I was unable to repro the issue that WebGrid will never pass from “Adding new row…” stage.
Look forward for your response.
Hi, Yes, that sample works for me too. See comments above, the problem lies when I bind to a dtaaset based on a stored procedure call. Ive attached another sample which does show the issue. Ive also attached a sql script to recreate the backend.
I look forward to hearing from you, and thanks again
Thank you for the sample. I am able to replicate the issue. However, this issue happened because you used improper properties. I found that Hierarchical="true" caused your issue. Your grid structure is a flat WebGrid not hierarchical.Also, I found that your WebGrid loaded in pageLoad which should not be there. We have an event 'IntializeDataSource'. You should bind WebGrid on those event.
protected void grdlistitemvalue_InitializeDataSource(object sender, DataSourceEventArgs e) { if (!Page.IsPostBack) { SqlConnection sqlConn; SqlCommand sqlCmd; String strConstring; int intUserID; strConstring = @"Data Source=HANDY-PC\SQLEXPRESS;Initial Catalog=gsportal_2010;Integrated Security=True"; sqlConn = new SqlConnection(strConstring); sqlConn.Open(); sqlCmd = new SqlCommand(); sqlCmd.Connection = sqlConn; sqlCmd.CommandTimeout = 30; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandText = "list_item_get_all"; SqlParameter objParam1 = new SqlParameter(); objParam1.ParameterName = "lstClientID"; objParam1.Value = 1; SqlParameter objParam2 = new SqlParameter(); objParam2.ParameterName = "lstID"; objParam2.Value = "5"; sqlCmd.Parameters.Add(objParam1); sqlCmd.Parameters.Add(objParam2); SqlDataAdapter RequestDA = new SqlDataAdapter(); RequestDA.SelectCommand = sqlCmd; DataSet RequestDS = new DataSet(); RequestDA.Fill(RequestDS, "RequestType"); e.DataSource = RequestDS.Tables[0]; sqlConn.Close(); } }
Hope this helps.
Thanks for looking at this Handy. Ive implemented your suggested fixes, but I still have the problem (see attached sample with your changes implemented).
Can you provide an attachment showing your working fix?
Your attachment is corrupted. So, I enclosed my modified sample. Hope this helps.
Handy,
The sample you attached doesnt work for me. Im getting an "object reference not set to an instance..." error when I try to add a row (see attached screenshot). I notice you commented out the contents of the "handleError" function, which I think was hiding the error I am now seeing all along. One thing I did try was calling "retrieveStructure" in the grids OnPrepareDataBinding event. This allowed the row to be added, but, the grid then shows all of the columns in the datasource, which i dont want (and, I notice in the call lifecycle, the initializeLayout event happens before
One thing I did try was calling "retrieveStructure" in the grids OnPrepareDataBinding event. This allowed the row to be added, but, the grid then shows all of the columns in the datasource, which i dont want (and, I notice in the call lifecycle, the initializeLayout event happens before
Can you confirm that your sample works? If so, can you attache a movie clip of it running?
Have run directly my pages? Or you only discard Hierarchical=true properties? I also got the same error and found out that DefaultFilterType="Contain properties in your itmText WebGridColumn caused the issue.
Please try to remove it and let me know if it works on you or not.
I ran your page directly, but it didnt work for me. I also removed the DefaultFilterType property from my own page, as you suggested, but it still doesnt work.
This seems to be a bug with the grid I think. You say it is working for you, but, the same code does not work for me.
My attached sample included the intersoft assemblies as I am using them, so that rules out a difference in the versions we are using as being the problem.
Can you please take another look at the attached sample, as I have it now. Ive also attached a screenshot of my current error.I really do need to get this working as soon as I can now Handy.
Ok, that is more details ( used WebGrid 7 before ) . I accidentally forgot to check your dll version because I just deleted it when I noticed that you did not use the latest hotfix at beginning. Please ensure that you are using the latest assemblies ( WebGrid and WebUIFramework). However, this issue also occured in the latest WebGrid6. I will submit this bug to our developer teams. Thank you for your information.
Thanks Handy. the application we are using is fairly evolved, and we dont want to update to V7 at the moment. Do you have an idea of when a fix might be available for this in V6 of the assemblies?
Currently, there is no workaround for your sample.
You said you were submitting this as a bug fix request to your development team, are you saying their is not going to be a bug fix / update sent out for this issue?
Please ignore my previous message. I am sorry for not being detail. Our developer will fix this issue in next hotfix, but there is no workaround for your issue. You will need to wait for the hotfix.
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