|
xxx
Utility Belt:
Search Demo C# SQLserver
by Charles Carroll
The code below calls "Utility Belt" functions.
The Search Code is one demo of Database "Utility Belt" functionality.
filename=/experiments/utilitybelt/vercurrent/ubdemo_search_sqlclient_cs.aspx
<%@ debug="true" %>
<%@ Import Namespace="LearnASP" %>
<%@ Assembly src="utilitybelt.vb" %>
<script language="C#" runat="server">
UtilityBelt ub1=new UtilityBelt();
string strConnect;
protected void Page_Load(Object S, EventArgs E)
{
ub1.Options("debug-on");
strConnect="LearnAspSamples";
if (!IsPostBack)
{
ub1.DBPopulate(strConnect,"select distinct city from publishers",cy);
ub1.DBPopulate(strConnect,"select distinct state from publishers",st);
ub1.DBPopulate(strConnect,"select distinct zip from publishers",zp);
ub1.DBPopulate(strConnect,"select count(distinct(city)) as citycount From publishers",cycount);
ub1.DBPopulate(strConnect,"select count(distinct(state)) as statecount From publishers",stcount);
ub1.DBPopulate(strConnect,"select count(distinct(zip)) as zipcount From publishers",zpcount);
}
}
protected void GetResults_Click(Object S, EventArgs E)
{
string strWhereClause="";
string strPrefix="";
if (chkcy.Checked==false & chkst.Checked==false & chkzp.Checked==false)
{
return;
}
if (chkcy.Checked)
{
strWhereClause += " city='" + cy.SelectedItem.Text + "' ";
strPrefix=" AND ";
}
if (chkst.Checked)
{
strWhereClause += strPrefix + " state='" + st.SelectedItem.Text + "' ";
strPrefix=" AND ";
}
if (chkzp.Checked)
{
strWhereClause += strPrefix + " zip='" + zp.SelectedItem.Text + "' ";
}
ub1.DBPopulate(strConnect,"select * from publishers WHERE " +strWhereClause,grdSearchResults);
}
</script>
<html><head>
<title>Utility Belt Demo</title>
</head>
<body bgcolor="#FFFFFF">
<form runat="server">
<asp:Table id="tbltest" runat="server" GridLines="both" BorderWidth="1px">
<asp:TableRow>
<asp:TableCell>City (<asp:literal id="cycount" runat="server"/>)</asp:TableCell>
<asp:TableCell><asp:dropdownlist id="cy" datatextfield="city" runat="server" /></asp:TableCell>
<asp:TableCell><ASP:checkbox id="chkcy" text="include City in Search?" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>State (<asp:literal id="stcount" runat="server"/>)</asp:TableCell>
<asp:TableCell><asp:dropdownlist id="st" datatextfield="state" runat="server" /></asp:TableCell>
<asp:TableCell><ASP:checkbox id="chkst" text="include State in Search?" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>Zip (<asp:literal id="zpcount" runat="server"/>)</asp:TableCell>
<asp:TableCell><asp:dropdownlist id="zp" datatextfield="zip" runat="server" /></asp:TableCell>
<asp:TableCell><ASP:checkbox id="chkzp" text="include Zip in Search?" runat="server"/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell> </asp:TableCell>
<asp:TableCell><ASP:BUTTON text="Get the Results" onclick="GetResults_Click" runat="server" /></asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:datagrid id="grdSearchResults" EnableviewState="false" runat="server" />
</form>
</body></html>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|