<tr> <td colspan="6" class="text_color"> <asp:TextBox runat="server" ID="txtQuery" Width="20%"></asp:TextBox> <asp:DropDownList ID="ddlReportInstance" runat="server"></asp:DropDownList> <asp:Button runat="server" ID="btnQuery" CssClass="formButton" Text="搜索" OnClick="btnQuery_Click" /> <a href="#" onclick="ShowQuery()">高级查询</a> 页显示条数设置 <asp:DropDownList ID="seletPageNum" runat="server"></asp:DropDownList> </td> </tr> <tr> <td colspan="6"> <asp:UpdatePanel runat="server" ID="UpdatePanel2"> <ContentTemplate> <SOA:DeluxeGrid ID="dgDataSource" runat="server" DataSourceID="datasource" AllowSorting="true" OnSorting="dgDataSource_Sorting" PageSize="20" AutoGenerateColumns="False" DataSourceMaxRow="0" AllowPaging="True" CssClass="dataList" Width="100%" OnRowDataBound="dgDataSource_RowDataBound"> <%-- <Columns> <asp:TemplateField HeaderText="操作" Visible="false" SortExpression=""> <ItemTemplate> <div> <asp:LinkButton runat="server" ID="btnEdit">编辑</asp:LinkButton> <asp:LinkButton runat="server" ID="btnDel">删除</asp:LinkButton> </div> </ItemTemplate> </asp:TemplateField> </Columns>--%> <HeaderStyle CssClass="head" /> <PagerStyle CssClass="pager" /> <RowStyle HorizontalAlign="Left" CssClass="item" /> <AlternatingRowStyle HorizontalAlign="Left" CssClass="aitem" /> <EmptyDataTemplate> 暂时没有您需要的数据 </EmptyDataTemplate> <PagerSettings FirstPageText="<<" LastPageText=">>" Mode="NextPreviousFirstLast" NextPageText="下一页" Position="Bottom" PreviousPageText="上一页"></PagerSettings> </SOA:DeluxeGrid> <SOA:DeluxeObjectDataSource ID="datasource" runat="server" EnablePaging="True" TypeName="MCS.Library.SOA.DataObjects.DataSources.ProcessQueryDataSource" OnSelecting="dataSource_Selecting"> <SelectParameters> <asp:Parameter Name="tempID" Type="String" /> <asp:Parameter Direction="InputOutput" Name="totalCount" Type="Int32" /> </SelectParameters> </SOA:DeluxeObjectDataSource> <asp:HiddenField runat="server" ID="hfDSID" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="click" /> </Triggers> </asp:UpdatePanel> </td> </tr>
如果用这个,平台上控件不支持
<asp:DropDownList ID="seletPageNum" runat="server" AutoPostBack="true"></asp:DropDownList>
下拉框触发查询按钮点击事件,控制页长值。
<script type="text/javascript"> $("#seletPageNum").change(function(){ document.getElementById("btnQuery").click(); }) </script>
protected void dataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { dgDataSource.PageSize = Convert.ToInt32(seletPageNum.SelectedValue); if (e.ExecutingSelectCount == false) { e.InputParameters["tempID"] = Template.Id; WhereSqlClauseBuilder where = new WhereSqlClauseBuilder(); List<KeyAndValue> dataItems = new List<KeyAndValue>(); if (!hfQueryStr.Value.IsNullOrEmpty()) dataItems = JSONSerializerExecute.Deserialize<List<KeyAndValue>>(hfQueryStr.Value); foreach (var item in dataItems) { var parameter = Template.Config.DataQuery.SearchParameters.Find(p => p.ParameterName == item.Key); if (parameter != null) where.AppendItem(item.Key, TSqlBuilder.Instance.CheckUnicodeQuotationMark(item.Value), "", parameter.FormatString, true); } if (!txtQuery.Text.IsNullOrEmpty()) {//【普通搜索】 if (Template.Config.DataQuery.DefaultWhereClause.Contains("=") == true) where.AppendItem(Template.Config.DataQuery.DefaultWhereClause.TrimEnd(‘=‘), txtQuery.Text); else where.AppendItem(Template.Config.DataQuery.DefaultWhereClause, "%" + txtQuery.Text + "%", "LIKE"); } if (!string.IsNullOrEmpty(Template.DefaultValue)) { //没值查询所有时间的数据 if (Template.IsDefault) { if (!ddlReportInstance.SelectedValue.IsNullOrEmpty()) {//【普通搜索】 if (ddlReportInstance.Items.Count > 0) where.AppendItem(ReportTimeName, ddlReportInstance.SelectedItem.Text); } } else { where.AppendItem(ReportTimeName, DataFormTemplateQueryDataAdapter.Instance.GetReportTimeName(Template.DefaultValue)); } } this.datasource.Condition = where; } }
protected void btnQuery_Click(object sender, EventArgs e) { this.dgDataSource.DataBind(); }
时间: 2024-11-05 21:46:13