我尝试使用单选按钮列表让用户选择是否要将gridview的当前页面或整个gridview导出到excel工作表,但只有当前页面在工作,至于将整个gridview导出到一个excel表,它只显示标题行。这里有什么问题,与radiobuttonlist的selectedindex有关吗?
protected void btnExport_Click(object sender, EventArgs e)
{
if (this.RadioButtonList1.SelectedIndex == 1)
{
// the user wants all rows in the current page, set pagesize and rebind
this.GridView1.PageSize = 10;
this.GridView1.DataBind();
}
else if (this.RadioButtonList1.SelectedIndex == 2)
{
// the user wants all rows exported, have to turn off paging and rebind
this.GridView1.AllowPaging = false;
this.GridView1.DataBind();
}
GridViewExportUtil.Export("ContactsInformation.xls", this.GridView1);
}