Praveen Maurya

Praveen Maurya

  • 1.9k
  • 146
  • 18.7k

Search in Datagridview

May 3 2018 11:39 AM
I have a datagridview in my project and i have merged two table in that gridview using inner join sql query and now i want to search in that gridview 
 
Code is like ..
 
  1. public void Show_items()  
  2.         {    
  3.             con.Open();  
  4.             SqlDataAdapter sda1 = new SqlDataAdapter("select ITEM.ITEM_NAME, STOCK.QTY, ITEM.SALEPRICE, ITEM.GST, ITEM.TOTALSALEPRICE from ITEM inner join STOCK on ITEM.ITEM_NAME = STOCK.ITEM_NAME ", con);  
  5.             DataTable dt1 = new DataTable();  
  6.             sda1.Fill(dt1);  
  7.             search_item_grid.Rows.Clear();  
  8.             foreach (DataRow dr1 in dt1.Rows)  
  9.             {                                 
  10.                 int n = search_item_grid.Rows.Add();  
  11.                 search_item_grid.Rows[n].Cells[0].Value = dr1[0].ToString();  
  12.                 search_item_grid.Rows[n].Cells[1].Value = dr1[1].ToString();  
  13.                 search_item_grid.Rows[n].Cells[2].Value = dr1[2].ToString();  
  14.                 search_item_grid.Rows[n].Cells[3].Value = dr1[3].ToString();  
  15.                 search_item_grid.Rows[n].Cells[4].Value = dr1[4].ToString();                  
  16.             }  
  17.             con.Close();              
  18.         }  
 

Answers (5)