Click here to Skip to main content
13,200,729 members (52,677 online)
Rate this:
Please Sign up or sign in to vote.
i have a data grid view that has as datasource one data table of dataset. when i try to add a new row to datatable sometimes datagridview is not displaying any rows. when it happens, it does it just from the application startup(form shows) i mean that the datagridview does not display lines from the beginning, not after displaying some and the rest are not being displayed .
I have to close the application to fix the issue.

plz any advice
Posted 13-Dec-12 4:48am
Updated 13-Dec-12 7:50am
HashamAhmad 13-Dec-12 10:55am
can you post a sample code about what you actually doing?
90jeri 13-Dec-12 11:48am
i set the datasource of dg with
dataset.Tables["BillLinesDt"].DefaultView.RowFilter = "ID = " + id;
dgBill.DataSource = dataset.Tables["BillLinesDt"].DefaultView;</pre>

i create new row with this :
DataRow newRow = dataset.Tables["BillLinesDt"].NewRow();
i set the values of each column
newrow[0] = value1;
newrow[1] = value2;

and then i add this new row to the datatable with this

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You have RowFilter set to the dataset to filter out the data based on ID. remove the filter and check your display.

Check this line of code in your source.
dataset.Tables["BillLinesDt"].DefaultView.RowFilter = "ID = " + id;
90jeri 13-Dec-12 13:18pm
in dataset.Tables["BillLinesDt"] it keeps lines of bills so i need to get only the rows of a specific bill thats why i need that filter
jibesh 13-Dec-12 13:21pm
I understand that but since you said some of the rows couldnt added to the grid view can you also check the Id's of the newly added row.
Are you able to reproduce this problem all the time?> If yes for what value the grid doesnt display your data. You can use the 'Improve Question'link to update your questions if you want.
90jeri 13-Dec-12 13:54pm
no i can't reproduce this problem it just happens some times. i know that rows are saved in dataset.Tables["BillLinesDt"] but they aren't displayed. so if i close the form and open it again everything is okay
jibesh 13-Dec-12 14:03pm
From the above code What i can read is you will see the problem(actually it's not a problem because we asked to do so by filtering the view) when records that doesnt matches the 'Id' value set to the filter. try to debug your code for what values it failed to display on the grid. you can use the System.Diagnostics.Trace class to log your output for debugging.
90jeri 13-Dec-12 14:19pm
i've checked that is the same id ('id' is a foreign key to the id of the actual bill that is created so when i have only one bill it happened)
jibesh 13-Dec-12 14:28pm
you need to provide some more details about your problem. i would say this is a design issue nothing to do with the datagridview control you need to overlook your system design and what we have here is limited knowledge about your system and we cannot read your mind. better provide more detail about your system rather someone guessing all the possible cases one by one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100