473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to select row from datagridview when column have cells is empty

fugio
4 New Member
Hi there !
how to select row from datagridview when column have cells is empty
I tried this but nothing worked
Please help on this
Expand|Select|Wrap|Line Numbers
  1.  private void selectrow()
  2.         {
  3.             int i;
  4.             for( i=0 ;i<dataGridView1 .Rows .Count -1;i++)
  5.             {
  6.                 string row = dataGridView1.Rows[i].Cells["Name"].Value.ToString();
  7.                 if (row =="")
  8.                 {
  9.                     sqlconn.Open();
  10.                     string sqlquery = "select * from tbl... where id='" + dataGridView1.Rows[i].Cells["id"].Value.ToString() + "'";
  11.                     SqlCommand sqlcmd = new SqlCommand(sqlquery, sqlconn);
  12.                     SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmd);
  13.                     DataTable dt = new DataTable();
  14.                     sqlda.Fill(dt);
  15.                     dataGridView1.DataSource = dt;
  16.                     sqlconn.Close();
  17.                 }
  18.  
  19.  
  20.             }
  21.  
  22.         }
Jul 21 '13 #1
0 1138

Sign in to post your reply or Sign up for a free account.

Similar topics

7
11895
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] =...
5
2314
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
1
3263
by: Crazy Cat | last post by:
Hi, whenever the underlying query being called by EXEC in the following has an empty result set I get the following error -- Invalid Data for 'Numeric' when EXEC returns empty row. However if I...
3
75009
by: David Veeneman | last post by:
I'm trying to set images in a bound DataGridView image column. My enum has three possible values, and I have an image that I want to show for each value: EnumValue.OK --GreenLight.gif...
3
94211
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
0
916
by: bh | last post by:
I am working on a calendar application that requires me to let the user select a range of adjacent cells by: 1-clicking in the start cell (start of range) 2-holding down the mouse key...
2
16488
by: OceanBreeze | last post by:
Border drawn in C# Table programmatically even if several adjacent horizontal & vertical cells are empty in the table I want to programmatically have border on each and every row and column in the...
3
3149
by: sankarpulivarthi | last post by:
Hi i have a checkbox in first datagridview . when it is checked it should get that row values.and iam trying to display that checked row values in a second datagridview after clicking a button....
1
8703
by: MFayaz | last post by:
Hello! I have to refresh datagridview when database update , IS there any way to solution that my datagridview auto refresh when any user update database. Thanks in Advance
0
2836
by: visweswaran2830 | last post by:
Hi, I am having datagridview in that I have datagridview combobox column and noraml textfield. I want to know that how can I load selected value in that combox box when I am loading all entered...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.