Hi all,
Searching DataGrid Value from TextBox is a good idea .
// Hare i use a list which will retrive data from database for DataGrid ItemsSource
List<EBuildingSetup> listbuildingInformation = ObjBBuildingSetup.GetAllBuildingInformation(eBuildingSetupObj);
dataGrid1.ItemsSource = listbuildingInformation;
//For Your button click:
for (int i = 0; i < dataGrid1.Items.Count-1; i++)
{
EBuildingSetup objEBuildingSetup = (EBuildingSetup)dataGrid1.Items[i];
// Hare it is important that which field data you want to search like BuildingType in your grid
if(objEBuildingSetup.BuildingType==textBox2.Text.Trim())
{
dataGrid1.SelectedIndex = i;
}
}
Searching DataGrid Value from TextBox is a good idea .
// Hare i use a list which will retrive data from database for DataGrid ItemsSource
List<EBuildingSetup> listbuildingInformation = ObjBBuildingSetup.GetAllBuildingInformation(eBuildingSetupObj);
dataGrid1.ItemsSource = listbuildingInformation;
//For Your button click:
for (int i = 0; i < dataGrid1.Items.Count-1; i++)
{
EBuildingSetup objEBuildingSetup = (EBuildingSetup)dataGrid1.Items[i];
// Hare it is important that which field data you want to search like BuildingType in your grid
if(objEBuildingSetup.BuildingType==textBox2.Text.Trim())
{
dataGrid1.SelectedIndex = i;
}
}
Comments
Post a Comment