We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Reg: DataView

Hi, This is my code to fill the databound grid using dataview. [maxRow = 11] private void FillDetailedHistory(DataView dvLatestHistory) { dvLatestHistory.Sort = "HISTORY_DATE DESC"; int rowCount = dvLatestHistory.Count; if (rowCount > maxRows) { DateTime filterDate = Convert.ToDateTime(dvLatestHistory[maxRows][historyDateColumn]); DateTime firstDate = Convert.ToDateTime(dvLatestHistory[0][historyDateColumn]); dvLatestHistory.RowFilter = "HISTORY_DATE > ''" + filterDate +"'' AND HISTORY_DATE <= ''" + firstDate +"''"; } sgbDetailedHistory.BeginUpdate(); sgbDetailedHistory.EnableAddNew = false; this.sgbDetailedHistory.DataSource = dvLatestHistory; sgbDetailedHistory.EndUpdate(true); this.dvSave = dvLatestHistory; } This is my code to insert row in to databound grid control. private void btnInsertRow_Click(object sender, System.EventArgs e) { try { DataRow dr = dvSave.Table.NewRow(); dr["ASSET_ID"] = this.allInfoData.Asset.AssetId; if (this.sgbDetailedHistory.Model.RowCount == 0) { dr[historyDateColumn] = System.DateTime.Now.Date; } else { dr[historyDateColumn] = Convert.ToDateTime(this.sgbDetailedHistory[1, 1].Text).AddDays(1); } dvSave.Table.Rows.Add(dr); this.FillDetailedHistory(dvSave); } catch (Exception ex) { Logger.WriteLogEntry("Error while Inserting New Row", ex, LogType.Error); } } My question is,If the grid contain >=11 rows, i can not insert new row in to grid. If less than 11 rows i can. What could be the problem..? Note: Pk: Assetid & HistoryDate Thanks, Anna

5 Replies

AD Administrator Syncfusion Team July 29, 2005 09:26 AM UTC

What error are you getting? My guess is that this has nothing to do with the grid. In your code snippets, comment out every line that uses the grid. Does the remaining code work to add a new row to your dataview? You should look at the values you have set in your new row, and make sure they satisfy the rowfilter you have added to this dataview. If they do not, then that would explan why the new row does not appear in teh dataview. (Though if you dropped another grid on your form and just made the datasource of that grid be the datatable, I suspect the new row wold appear there.)

AS Anna Srinivasan July 29, 2005 09:42 AM UTC

Hi, I am not getting any error. But row count does not increse after adding new row to dataview, if row count >= 11. If it is < 11 , i can. Note: If i remove the filter condition, every thing is Perfectly fine. Any idea...........!

AD Administrator Syncfusion Team July 29, 2005 09:48 AM UTC

As I said above, this suggests that the new row you are adding does NOT satisfy the RoweFilter that you have set on the dataview. So, look at the values in the new row and compare them to the RowFilter to see what you need to do to make the new row satisfy the RowFilter.

AS Anna Srinivasan July 29, 2005 10:43 AM UTC

Hi, What i am trying to saying is, before going to filter condition itself, the row count does not increse.

AD Administrator Syncfusion Team July 29, 2005 11:08 AM UTC

Things work as expected in this sample. Can you tell me how ot see the problem with this sample? http://www.syncfusion.com/Support/user/uploads/GDBG_AddRow_15f6a464.zip If you put a stop on the every line where you assign the RowFilter, (even if it is in the designer gerenated code), and put a stop on the line where you add the new row, I suspect that the rowfilter line is being hit before the addnew row line. This would explain the behavior you are seeing. Once the filter is set, that filter continues to apply until you change it to something else. So, new rows added after the filter has been set must satisfy the existing filter.

Live Chat Icon For mobile
Up arrow icon