Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
HI!
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 5:48am
90jeri884
Edited 13-Dec-12 8:50am
v2
Comments
90jeri at 13-Dec-12 11:48am
   
i set the datasource of dg with
<pre>
dataset.Tables["BillLinesDt"].DefaultView.RowFilter = "ID = " + id;
dgBill.DataSource = dataset.Tables["BillLinesDt"].DefaultView;</pre>
 
i create new row with this :
<pre>
DataRow newRow = dataset.Tables["BillLinesDt"].NewRow();
</pre>
i set the values of each column
<pre>
newrow[0] = value1;
newrow[1] = value2;
</pre>
 

and then i add this new row to the datatable with this
<pre>dataset.Tables["BillLinesDt"].Rows.Add(newRow);</pre>

1 solution

Rate this: bad
good
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;
  Permalink  
Comments
90jeri at 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 at 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 at 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 at 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 at 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 at 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
0 OriginalGriff 381
1 Sergey Alexandrovich Kryukov 245
2 Marcin Kozub 225
3 Praneet Nadkar 217
4 /\jmot 189
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2014
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