asked on
Protected Sub BtnCustSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCustSearch.Click
Dim StrCustomerCheck As String
Dim CmdCustometSearch As New SqlCommand
Dim SerachValue = txtSearchCustomer.Text
StrCustomerCheck = "Select Customers.Customerid,Customers.Companyname As Company,Customers.City,Customers.State,StateProvince.Countryregionname as Country from Customers,Stateprovince where Customers.Stateprovinceid=StateProvince.Stateprovinceid and CompanyName LIKE '%SerachValue%' order By CompanyName ASC"
SQlCustomers.SelectCommand = StrCustomerCheck
GrdCustomer.DataSource = SQlCustomers
MyConn.Close()
ASKER
ASKER
ASKER
<asp:GridView ID="GrdCustomer" runat="server" AutoGenerateColumns="False"
DataKeyNames="Customerid" DataSourceID="SQlCustomers" onselectedindexchanged="GrdCustomer_SelectedIndexchanged"
AllowPaging="True"
AllowSorting="True" Width="599px" EnableViewState="False">
<Columns>
<asp:commandfield showselectbutton="true"
headertext="Select Customer"/>
<asp:BoundField DataField="Customerid" InsertVisible="false" HeaderText="Customerid" />
<asp:BoundField DataField="Company" HeaderText="Company" />
<asp:BoundField DataField="City" HeaderText="City"/>
<asp:BoundField DataField="State" HeaderText="State"/>
<asp:BoundField DataField="Country" HeaderText="Country"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SQlCustomers" runat="server"
ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>"
SelectCommand="Select Customers.Customerid,Customers.Companyname As Company,Customers.City,Customers.State,StateProvince.Countryregionname as Country from Customers,Stateprovince where Customers.Stateprovinceid=StateProvince.Stateprovinceid order By CompanyName ASC">
</asp:SqlDataSource>
<table><tr><td>
<asp:TextBox ID="txtSearchCustomer" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="ReqCustomer" runat="server" ErrorMessage="*"
ControlToValidate="txtSearchCustomer"></asp:RequiredFieldValidator></td>
<td><asp:Button ID="BtnCustSearch" runat="server" Text="Search" /></td></tr></table>
'Codebehind-==================
Protected Sub BtnCustSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCustSearch.Click
Dim StrCustomerCheck As String
Dim CmdCustometSearch As New SqlCommand
Dim SerachValue = txtSearchCustomer.Text
StrCustomerCheck = "Select Customers.Customerid,Customers.Companyname As Company,Customers.City,Customers.State,StateProvince.Countryregionname as Country from Customers,Stateprovince where Customers.Stateprovinceid=StateProvince.Stateprovinceid and CompanyName LIKE '%SerachValue%' order By CompanyName ASC"
SQlCustomers.SelectCommand = StrCustomerCheck
GrdCustomer.DataBind()
MyConn.Close()
End Sub
Protected Sub BtnCustSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCustSearch.Click
Dim StrCustomerCheck As String
Dim SerachValue = txtSearchCustomer.Text
StrCustomerCheck = "Select Customers.Customerid,Customers.Companyname As Company,Customers.City,Customers.State,StateProvince.Countryregionname as Country from Customers,Stateprovince where Customers.Stateprovinceid=StateProvince.Stateprovinceid and CompanyName LIKE '%SerachValue%' order By CompanyName ASC"
SQlCustomers.SelectCommand = StrCustomerCheck
GrdCustomer.DataSource = SQlCustomers.Select(DataSourceSelectArguments.Empty)
GrdCustomer.DataBind()
End Sub
ASKER
ASKER
ASKER
StrCustomerCheck = "Select Customers.Customerid,Customers.Companyname As Company,Customers.City,Customers.State,StateProvince.Countryregionname as Country from Customers,Stateprovince where Customers.Stateprovinceid=StateProvince.Stateprovinceid and CompanyName LIKE '%@SearchValue%' order By CompanyName ASC"
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
something like
GrdCustomer.DatasourceID = sqldatasource.id
and then databind after that