效果如下圖
aspx的程式如下
<body>
<form id=
<script type=
//<![CDATA[
function WebForm_OnSubmit() {
$
border:
}
})
return true;
}
//]]>
</script>
<fieldset >
<legend><font color=
<table id=
<tr>
<td class=
<td class=
<asp:DropDownList ID=
</td>
<td class=
<td class=
<asp:TextBox ID=
<asp:TextBox ID=
</td>
<td>
<asp:Button ID=
OnClientClick=
</td>
</tr>
</table>
</fieldset>
<div id=
<div >
<asp:GridView ID=
CellPadding=
CellSpacing=
Font
PagerStyle
onpageindexchanging=
<AlternatingRowStyle BackColor=
<FooterStyle BackColor=
<HeaderStyle BackColor=
<PagerSettings FirstPageImageUrl=
LastPageImageUrl=
NextPageImageUrl=
Position=
<PagerStyle BackColor=
<RowStyle BackColor=
<SelectedRowStyle BackColor=
</asp:GridView>
</div>
<asp:ObjectDataSource ID=
onselecting=
</asp:ObjectDataSource>
<div >
<asp:Button ID=
onclick=
</div>
</div>
<script type=
$(document)
$
})
</script>
</form>
</body>
後端程式如下
protected void Page_Load(object sender
{
if (!IsPostBack)
{
QDDLReport
QDDLReport
QDDLReport
QtxtsDate
QtxteDate
}
else
{
//不同的報表有不同的SelectMethod
if (QDDLReport
{
ObjectDataSource
ObjectDataSource
}
else if (QDDLReport
{
ObjectDataSource
ObjectDataSource
}
else if (QDDLReport
{
ObjectDataSource
ObjectDataSource
}
}
}
protected void ObjectDataSource
{
System
if (dt == null || dt
div_count
else
div_count
}
protected void btnToExcel_Click(object sender
{
if (gvList
return;
Response
Response
Response
System
System
//關閉換頁跟排序
gvList
gvList
gvList
HtmlForm hf = new HtmlForm()
Controls
hf
hf
Response
Response
}
protected void ObjectDataSource
{
//首次進入頁面不Query
if (!IsPostBack)
e
}
protected void btnQuery_Click(object sender
{
QueryDataBLL bll = new QueryDataBLL()
ObjectDataSource
if (QDDLReport
{
this
//依Query的需求設定Parameter
Parameter para
para
ObjectDataSource
Parameter para
para
ObjectDataSource
}
else if (QDDLReport
{
this
//依Query的需求設定Parameter
// 略
}
else if (QDDLReport
{
this
//依Query的需求設定Parameter
// 略
}
this
}
protected void gvList_PageIndexChanging(object sender
{
ObjectDataSource
}
private void createGVColumns(System
{
//依不同的查詢結果設定gridview欄位
gvList
for (int i =
{
BoundField bf = new BoundField()
bf
bf
gvList
}
}
QueryDataBLL 的 GetAQueryData 與 GetAQueryDataSchema 都是回傳 Datatable
From:http://tw.wingwit.com/Article/program/net/201311/13280.html