Tuesday 23 December 2014

set value in combobox in C#

 if (cmbHRU.Items.Count > 0)
                    {
                        // Search the Item that matches the string
                        int index = cmbHRU.FindString(_dtExistingStdata.Rows[0]["hru_id"].ToString());
                        // Select the Item in the Combo
                        cmbHRU.SelectedIndex = index;
                    }

Wednesday 10 December 2014

get single record from table in C# with where condition

 DataTable dtDataStation = objStationMaster.GetStationDetails();
                var stDetailId = (from DataRow dr in dtDataStation.Rows
                                  where Convert.ToString(dr["Station"]) == txtStation.Text
                                  select (string)dr["Identifier"]).FirstOrDefault();