我想从网格视图中取消分页。我通过重定向在javascript中这样做。我将在下面解释。但我宁愿取消分页,只需在更新面板中重新加载Gridview。怎么办?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.Params("R") = "1" Then
GridView1.AllowPaging = False
End If
End Sub
function Paging(remove) {
var txt = $get('<%=TextBox1.ClientID%>');
var query = window.location.search.substring(1);
//alert (query);
window.location = url + 'R=' + remove ;
txt.value = txt.value;
}
Dim bttnrempag As New Button
bttnrempag.ID = "bttnrempag"
bttnrempag.Text = " Paging"
bttnrempag.CssClass = "bttnMinEG"
bttnrempag.ValidationGroup = "alone"
bttnrempag.Attributes.Add("onclick", "Paging('1')")
Dim bttnallowpag As New Button
bttnallowpag.ID = "bttnallowpag"
bttnallowpag.Text = " Paging"
bttnallowpag.ValidationGroup = "alone"
bttnallowpag.CssClass = "bttnAddEG"
bttnallowpag.Attributes.Add("onclick", "Paging('0')")
//this is where i add the buttons to my Gridview
cell.Controls.Add(bttnrempag) '36
cell.Controls.Add(bttnallowpag)
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate >
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
DataSourceID="SqlDataSource1" Font-Names="Comic Sans MS" Font-Size="XX-Small"
Font-Bold="True" PageSize="15" >
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<Columns>
<asp:BoundField DataField="scan" HeaderText="Scan" SortExpression="scan" />
<asp:BoundField DataField="ScanType" HeaderText="ScanType" ReadOnly="True"
SortExpression="ScanType" />
<asp:TemplateField HeaderText="Item Desc."></asp:TemplateField>
<asp:BoundField />
<asp:BoundField />
<asp:BoundField />
<asp:BoundField />
<asp:BoundField />
<asp:BoundField />
<asp:BoundField />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<EmptyDataTemplate>
<head>
<meta http-equiv="refresh" content="5;URL=/Corporate_newpo/ReceivingLog.aspx?">
</head>
<script type="text/javascript" >
var count = 6;
var counter = setInterval("timer()", 1000); //1000 will run it every 1 second
function timer() {
count = count - 1;
if (count <= 0) {
clearInterval(counter);
//counter ended, do something here
return;
}
$get("timer").innerHTML = "The Table will Reload in " + count + " secs";
}
</script>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Large"
ForeColor="#993333" Text="No Data was Found for the Selected Filter"></asp:Label><br /><br />
<span id="timer" style="font-size:medium;color:blue"></span>
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
当然我在网格中有数据。我只是不在这里展示它。 如何在不使用变量重定向的情况下关闭分页,因为我在javascript中使用R进行此操作?
答案 0 :(得分:2)
这是javascript,用于关闭网格视图控件的分页
// get datagrid by rendered table name
var myGridView = document.getElementById('<%= grdvCategoryList.ClientID % >');
var intNumberOfRows = myGridView.rows.length;
myGridView.rows[intNumberOfRows-1].style.visibility='hidden';
myGridView.rows[intNumberOfRows-1].style.display='none';
return false;
这将隐藏网格视图控件的最后一行。希望能帮到你。
答案 1 :(得分:1)
在UpdatePanel中添加一些按钮:
GridView1.AllowPaging = False
GridView1.DataBind()
GridView1.AllowPaging = True
GridView1.DataBind()