Hi ......,
I Had Created Application Without Database . Using Grid View I Can Insert,Update Delete those Details From The Table. The Given Data Will be Stored in C# Code itself in XML Format.
In This Grid View I Had Saved The Data of Employee Details Like
Name , Age , Qualification , Salary
In This i Need to Create "Search Name" Text Box & Button. If I enter The Name in that and When i Click Search It Need to Show the Record of the Particular Employee. And (Mainly I Had Created Paging in Grid View) It Should Take And Come Records From All Pages If it Matches.
Technology Used By Me
Visual Studio 2010
ASP.NET 4.0 C#
With Warm Regards.....,
R.V.Rajagopalan
Loading

Jayakumar BalasubramaniamPosted Jun 4, 2014, 8:45 AM
protected void btnSearch_Click(object sender, EventArgs e)
The above is the SearchButton Click event for you . usr this code surely you will get solution.
here am binding the searched result again to the gridview so Gridview will display only the searched record.
I think now your problem gets solved ???
Rajagopalan R VPosted Jun 5, 2014, 7:33 AM
Thank You Very Much , To Spend Time For Me For this Search Concept. its Retrieving the Data What am Entering into Search Field, Its Working Fine.........
With Warm Regards.......,
R.V.Rajagopalan
Rajagopalan R VPosted Jun 4, 2014, 6:55 AM
Thanq Very Much For U R Reply First, The Above Code is Retrieving the Particular Row Details from Data Table Correctly But its Not Binding or Filtering the Particular Row Details in the Grid View Please Let Me Know Solution For that
With Regards.....,
R.V.Rajagopalan
Jayakumar BalasubramaniamPosted Jun 4, 2014, 4:49 AM
Please replace the foreach in the above reply with the foreach in this reply.
foreach (DataRow row in foundRow)
Jayakumar BalasubramaniamPosted Jun 4, 2014, 2:14 AM
DataSet dsSample = new DataSet();
Its the sample code for your xml I have hard coded the search name as SAI as per your xml . its retrieving only that row from the datatable.
Since that select statement will return collection of rows I used foreach to get values of retrieved records..
If you used ' name ' as primary field and you sure that there will be only one record with that 'name' there is no need of foreach.
For further clarifications call me :)
Jayakumar BalasubramaniamPosted Jun 4, 2014, 1:48 AM
Rajagopalan R VPosted Jun 4, 2014, 1:28 AM
xml version="1.0" standalone="yes"?>
<EmployeeDetails>
<Employee>
<name>RAJAGOPALANname>
<age>24age>
<gender>Malegender>
<qualification>B.Techqualification>
<Dept>ITDept>
<designation>Developerdesignation>
Employee>
<Employee>
<name>SAIname>
<age>23age>
<gender>Malegender>
<qualification>B.Techqualification>
<Dept>ITDept>
<designation>Developerdesignation>
Employee>
<Employee>
<name>MANOJname>
<age>26age>
<gender>Malegender>
<qualification>M.Techqualification>
<Dept>IN&SDept>
<designation>Sr.Developerdesignation>
Employee>
<Employee>
<name>RAJAname>
<age>27age>
<gender>Malegender>
<qualification>M.Techqualification>
<Dept>SEDept>
<designation>ProjectLeaddesignation>
Employee>
EmployeeDetails>
The Above one is My Sample XML Data. Where This XML Data Will be Stored in EmployeeDetails.xml file
I'm Retrieving these data in DataTable And Binding it into Gridview
from this i need to search particular Row
Based on Name
XML Tag Names Are Declared as Column name in Datatable
Jayakumar BalasubramaniamPosted Jun 3, 2014, 8:58 AM
Rajagopalan R VPosted Jun 3, 2014, 1:52 AM
protected void btnNameSearch_Click(object sender, EventArgs e)
{
BindGrid();
DataTable dt = new DataTable();
ds.ReadXml(Server.MapPath("EmployeeDetails.xml"));
dt = ds.Tables[0];
dt.Select("name='" + tbxEmployeeSearch.Text + "'");
DataRow[] foundRow = dt.Select("name='" + tbxEmployeeSearch.Text + "'");
}
Where
name = "Column Name for EmployeeName in DataTable"
tbxEmployeeSearch = Where in this Text Box only I Enter the Name to Search
btnNameSearch = ID of the Button Search
EmployeeDetails.xml = "It Will Store the Details of Employees Like Name,Age Salary in Xml Tag"
This is the Source Used By Me in My ProjectJayakumar BalasubramaniamPosted May 30, 2014, 6:06 AM
This functions works fine for me in the above code in dtALLRecords DataTable am handling one lakh record to search particular row.
I cant get your point in your last post please explain it clearly. and if you can upload your source code.
Rajagopalan R VPosted May 30, 2014, 5:30 AM
DataRow[] foundRow = dt.Select("name='"+tbxNameSearch.Text+"'");
It Loading Full grid Like Page Load
dt.Select
dt is Taking Full Data table Not a Particular Data set......,
With Regards.....,
R.V.Rajagopalan
Jayakumar BalasubramaniamPosted May 28, 2014, 10:36 AM
Jayakumar BalasubramaniamPosted May 28, 2014, 10:34 AM
Rajagopalan R VPosted May 28, 2014, 4:59 AM
dt.Select("name=" + tbxNameSearch.Text);
Error : Cannot find column [xxxx].is Occurring in the Above Area ,Please Let Me Know What Mistake I've Done on the Code
Given Text Box Value = " xxxx " For Search
The Code Placed By Me in Search Button Click Event
BindGrid();
DataTable dt = new DataTable();
ds.ReadXml(Server.MapPath("EmployeeDetails.xml"));
dt = ds.Tables[0];
dt.Select("name=" + tbxNameSearch.Text);
With Regards.....,
R.V.Rajagopalan
Jayakumar BalasubramaniamPosted May 27, 2014, 10:57 AM
Yeah there is a solution whenever you click the search button store the GridView DataSource in DataTable as
DataTable dt= new DataTable();
dt= GridViewName.DataSource as DataTable;
Now you got all values in Gridview included in all pages of gridview.
You can query this DataTable based on the value entered in the textBox searchname
as
dt.Select("Name="+txtSearchName.Text);
If you have any doubt in querying the DataTable refer these links.
1. http://msdn.microsoft.com/en-us/library/way3dy9w(v=vs.110).aspx
2. http://msdn.microsoft.com/en-us/library/det4aw50(v=vs.110).aspx
3. http://www.dotnetperls.com/datatable-select
4. http://stackoverflow.com/questions/1990946/datatable-select-with-multiple-conditions
The above said method works for me:)
rahul ahujaPosted May 27, 2014, 6:38 AM