Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a search page which has radio buttons for them to search specific data. How do i create a button so that when the 'View All' button is clicked, the gridview will show all data.

I need replies ASAP! Thank youuu :)
Posted
Updated 29-Dec-13 16:31pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Dec-13 23:07pm    
The question does not seem to make sense. It depends on the content of your data and the page.
Besides, "How Can I Display All Data In GridView" makes especially little sense, because "all data in grid view" is by definition is already shown in its grid view.

Perhaps you mean something else, which does make sense. Then use Improve question.

—SA
Gaurav Makwana 30-Dec-13 0:04am    
radio button default uncheck and without checked any radio button only write search code and click on that search code it will display all data

Hi,

As you mentioned that you have given options to search, so I think its very easy to implement View All functionality.
Its totally depends on the select query.
In your select query remove where condition or add all options in where condition then all results will be displayed.
For example if you have given
C#
1)Bus
2)Bike 
3)Car
in the options for the user to search then
IF user selects
C#
Bike 
in the option then your query would look like
SQL
SELECT * FROM VehicleDatabase WHERE VehilceType = 'Bike';

Now if you want to select all then your query would look like
SQL
SELECT * FROM VehicleDatabase WHERE VehilceType in ('Bike','Bus','Car');

Note: Datatype and fields are depends on your Database table.

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
C#
void ShowData()
{
    if (RadioButton1.Checked)
        GridView1.DataSource = GetAllData();
    else
        GridView1.DataSource = GetPartialData();

    GridView1.DataBind();
}

or
C#
void ShowData()
{
    if (RadioButton1.Checked)
    {
        GridViewAll.DataSource = GetAllData();
        GridViewAll.DataBind();
        GridViewAll.Visible = true;
        GridViewPartial.Visible = false;
    }
    else
    {
        GridViewPartial.DataSource = GetPartialData();
        GridViewPartial.DataBind();
        GridViewPartial.Visible = true;
        GridViewAll.Visible = false;
    }
}
 
Share this answer
 
v3

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