<asp:Button ID="btn" runat="server" OnClick="btnView_Click" CausesValidation="true" Text="Search" />
<asp:gridview id="gv" allowpaging="true" allowsorting="true" runat="server" autogeneratecolumns="False" datakeynames="StudentID" datasourceid="SqlDataSource1" >
<Columns>
<asp:BoundField DataField="IDString" HeaderText="Student ID" SortExpression="IDString" />
</Columns>
</asp:gridview>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:************* %>"
CancelSelectOnNullParameter="false" SelectCommand="Select=@*****"
OnSelecting="on_Selecting">
<SelectParameters>
<asp:Parameter Name="*****" />
</SelectParameters>
</asp:SqlDataSource>
2 {
3 string strFilter = GetFilterStr();
4 SqlDataSource1.FilterExpression = strFilter;
5 }
6
7 private string GetFilterStr()
8 {
9 StringBuilder strFilter = new StringBuilder();
10 strFilter.Append("1=1");
11
12 strFilter.AppendFormat(" and (XXXXX='{0}')", XXXX);
13 }
14
15
16
17 protected void btnView_Click(object sender, EventArgs e)
18 {
19 SqlDataSource1.SelectParameters["SchoolID"].DefaultValue = SchoolDropDownList1.SelectedValue.ToString();
20 gv.DataBind();
21 }
22
23