单击“查看全部”按钮时,如何在Gridview中显示所有数据? [英] How Can I Display All Data In Gridview When 'View All' Button is Clicked?

查看:130
本文介绍了单击“查看全部”按钮时,如何在Gridview中显示所有数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索页面,其中包含用于搜索特定数据的单选按钮。如何创建按钮,以便在单击查看全部按钮时,gridview将显示所有数据。



我需要尽快回复!谢谢youuu:)

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 :)

推荐答案





如你所说,你已经提供了搜索选项,所以我认为很容易实现查看全部功能。

完全取决于选择查询。

在您的选择查询中删除条件或在条件中添加所有选项然后将显示所有结果。

例如,如果您已经给出了

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
1)Bus
2)Bike 
3)Car

在用户搜索的选项中然后

如果用户选择

in the options for the user to search then
IF user selects

Bike 

然后您的查询看起来像

in the option then your query would look like

SELECT * FROM VehicleDatabase WHERE VehilceType = 'Bike';



现在,如果你想选择所有,那么你的查询看起来像是


Now if you want to select all then your query would look like

SELECT * FROM VehicleDatabase WHERE VehilceType in ('Bike','Bus','Car');



注意:数据类型和字段取决于您的数据库表。



希望这对你有所帮助。



问候,

RK


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

Hope this helps you a bit.

Regards,
RK


void ShowData()
{
    if (RadioButton1.Checked)
        GridView1.DataSource = GetAllData();
    else
        GridView1.DataSource = GetPartialData();

    GridView1.DataBind();
}






or

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;
    }
}


这篇关于单击“查看全部”按钮时,如何在Gridview中显示所有数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆