Friday, September 2, 2016

LINQ Search


using (POHDataContext pos = new POHDataContext())
            {
                var seachResult = pos.ProductTables.Where(p => p.ProductName.Contains(txtSearch.Text));
             

                grd_product.DataSource = seachResult;

            }

LINQ LOADGRD


 DataGridViewCell cell = null;
            foreach (DataGridViewCell selectedCell in grd_product.SelectedCells)
            {
                cell = selectedCell;
                break;
            }

            if (cell != null)
            {
                DataGridViewRow row = cell.OwningRow;
                txtId.Text = row.Cells["ProductId"].Value.ToString();
                txtProductName.Text = row.Cells["ProductName"].Value.ToString();
                txtProductPrice.Text = row.Cells["ProductPrice"].Value.ToString();
                txtStock.Text = row.Cells["Stock"].Value.ToString();
            }

No comments:

Post a Comment