Click here to Skip to main content
16,022,798 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone,

I am developing a SEARCH page for my website, where I want results fetched from the database.
Now obviously only the number of columns is fixed, and not the number of rows, which is dynamic in nature based on the search parameters, provided by the user. I know, the answer must be fairly simple but I'm new to c#, that is why I want to know the approach to achieve this.

Before giving the answer, kindly consider that all the database connections have been done, and results are residing in a DataTable dt, where they were brought through a DataAdapter da. Now,
I want the code for the section:


if(dt.Rows.Count>0)
{
//How to represent the fetched data??
}


Thanks in advance.
Posted
Updated 14-Jul-13 3:42am
v2
Comments
_Asif_ 14-Jul-13 10:03am    
You are just a step away, All you have to do is to google. You will surely find the solution :)

1 solution

Well the solution was really simple indeed... All I had to do was to set the source of the Grid view as the data table dt where the data was already fetched and stored.
Code:-

if (dt.Rows.Count > 0)
{
grid_view.DataSource = dt;
grid_view.DataBind();

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900