wilberforce2
IS-IT--Management
I seam to have an amazingly simple problem that I just cant seam to sort out.
I am intermediate at Classic ASP VB but am new to .Net.
The problem that I am having is to filter by three columns of a Gridview with textboxes.
Company Name, Postcode and Telephone
With classic ASP I would have dynamically built an SQL query using LIKE, however using .net when the textboxes are blank ie page loads no results come up until I do a search. I would like to have all records displayed and then drill down. I have been searching online for two days and cannot find anything that will help. There are plenty of tutorials doing simple grid searches but none of them display all records and then drill down.
Please Help.
I am intermediate at Classic ASP VB but am new to .Net.
The problem that I am having is to filter by three columns of a Gridview with textboxes.
Company Name, Postcode and Telephone
With classic ASP I would have dynamically built an SQL query using LIKE, however using .net when the textboxes are blank ie page loads no results come up until I do a search. I would like to have all records displayed and then drill down. I have been searching online for two days and cannot find anything that will help. There are plenty of tutorials doing simple grid searches but none of them display all records and then drill down.
Please Help.
Code:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<script runat="server">
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)
End Sub
</script>
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
<title>Administration Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" Width="561px" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="fldID">
<Columns>
<asp:BoundField DataField="fldCompanyName" HeaderText="fldCompanyName" SortExpression="fldCompanyName" />
<asp:BoundField DataField="fldPostcode" HeaderText="fldPostcode" SortExpression="fldPostcode" />
<asp:BoundField DataField="fldTelephone" HeaderText="fldTelephone" SortExpression="fldTelephone" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Data.mdb"
SelectCommand="SELECT [fldID], [fldCompanyName], [fldPostcode], [fldTelephone] FROM [tblData] WHERE ([fldCompanyName] LIKE '%' + ? + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="txtCompanyName" Name="fldCompanyName" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:AccessDataSource>
<table style="width: 476px">
<tr>
<td style="width: 54px; height: 21px">
Name</td>
<td style="width: 100px; height: 21px">
Telephone</td>
<td style="width: 153px; height: 21px">
Postcode</td>
</tr>
<tr>
<td style="width: 54px; height: 35px">
<asp:TextBox ID="txtCompanyName" runat="server" Width="135px"></asp:TextBox></td>
<td style="width: 100px; height: 35px">
<asp:TextBox ID="txtTelephone" runat="server"></asp:TextBox></td>
<td style="width: 153px; height: 35px">
<asp:TextBox ID="txtPostcode" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="cmdSearch" runat="server" Text="Search" />
<asp:Button ID="cmdAdd" runat="server" Text="Add" />
<asp:Button ID="cmdDelete" runat="server" Text="Delete" />
<asp:Button ID="cmdReset" runat="server" Text="Reset" />
<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="fldID"
DataSourceID="AccessDataSource2" DefaultMode="Edit" Height="50px" OnPageIndexChanging="DetailsView1_PageIndexChanging"
Width="558px">
<Fields>
<asp:BoundField DataField="fldID" HeaderText="fldID" InsertVisible="False" ReadOnly="True"
SortExpression="fldID" />
<asp:BoundField DataField="fldCompanyName" HeaderText="fldCompanyName" SortExpression="fldCompanyName" />
<asp:BoundField DataField="fldAddress1" HeaderText="fldAddress1" SortExpression="fldAddress1" />
<asp:BoundField DataField="fldAddress2" HeaderText="fldAddress2" SortExpression="fldAddress2" />
<asp:BoundField DataField="fldAddress3" HeaderText="fldAddress3" SortExpression="fldAddress3" />
<asp:BoundField DataField="fldTownCity" HeaderText="fldTownCity" SortExpression="fldTownCity" />
<asp:BoundField DataField="fldCounty" HeaderText="fldCounty" SortExpression="fldCounty" />
<asp:BoundField DataField="fldPostcode" HeaderText="fldPostcode" SortExpression="fldPostcode" />
<asp:BoundField DataField="fldTelephone" HeaderText="fldTelephone" SortExpression="fldTelephone" />
<asp:BoundField DataField="fldMobile" HeaderText="fldMobile" SortExpression="fldMobile" />
<asp:BoundField DataField="fldFax" HeaderText="fldFax" SortExpression="fldFax" />
<asp:BoundField DataField="fldEmail" HeaderText="fldEmail" SortExpression="fldEmail" />
<asp:BoundField DataField="fldWebsite" HeaderText="fldWebsite" SortExpression="fldWebsite" />
<asp:BoundField DataField="fldTherapy1" HeaderText="fldTherapy1" SortExpression="fldTherapy1" />
<asp:BoundField DataField="fldTherapy2" HeaderText="fldTherapy2" SortExpression="fldTherapy2" />
<asp:BoundField DataField="fldTherapy3" HeaderText="fldTherapy3" SortExpression="fldTherapy3" />
<asp:BoundField DataField="fldTherapy4" HeaderText="fldTherapy4" SortExpression="fldTherapy4" />
<asp:BoundField DataField="fldDescription" HeaderText="fldDescription" SortExpression="fldDescription" />
<asp:BoundField DataField="fldLat" HeaderText="fldLat" SortExpression="fldLat" />
<asp:BoundField DataField="fldLong" HeaderText="fldLong" SortExpression="fldLong" />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/Data.mdb"
SelectCommand="SELECT * FROM [tblData] WHERE ([fldID] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="fldID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>