Web Forms :: How To Show Search Result In A Gridview In A New Page
Jun 6, 2010
i have a requirement in which the user can search for other user he enters three char of the name clicks on the search button and a new window is opened and he can see all the search results in a gridview he can select one of them and this closes the new window and the details are populated on the previous page.
I am stored date in "smalldatetime" datatype as in databse.How can i particular textbox entered date(dd-mm-yyyy) used to fetch the row information from databse and shown in a gridview.
I am new at this VB/Microsoft Visual Web Developer 2010 Express thing. I am amaze that I even got this far and thatI manages to make this search page work. Below is the code and picture for this search page. It's working. However I want to transfer the result/the gridview onto a second page Result.aspx. But I tries all kind of thing and it just doesn't seem to want to cooperate with me. If anyone can give me some hint/some sample codes on how I might be able to transfer controlfrom one page onto another. I just have to learn it from a class extra credit project. Also in the picture above I am using a direct connection to an Access database not the ObjectDataSource. I was just playing around with it to see which is better. But I ended up going with direct connection to Access database.
<%@ Page Language="VB" ClassName="SenderClass" EnableSessionState="True" %> <head> <script runat="server"> Sub closeSite(ByVal sender As Object, ByVal e As EventArgs) Response.Write(" <script language='javascript'> { window.close(); }") End Sub Sub Page_Transfer(ByVal sender As Object, ByVal e As EventArgs) 'Storing in Context Session("SearchBox") = SearchBox.Text Session("ListBox") = ListBox1.Text Session("DropDownList") = DropDownList.DataTextFormatString 'Context.Items("DropDownList") = DropDownList.Text 'Server.Transfer("SearchResult.aspx") End Sub Sub Page_Transfer2(ByVal sender As Object, ByVal e As EventArgs) Dim field1 As String = ("SearchBox") Dim field2 As String = ("ListBox") Dim field3 As String = ("DropDownList") 'Dim TestString As String = ("SELECT * FROM [Books] WHERE (([Title] = ?) AND ([Category] = ?))") End Sub Sub Test(ByVal sender As Object, ByVal e As EventArgs) AccessDataSource1.SelectCommand = "SELECT * FROM BOOKS WHERE " If DropDownList.SelectedIndex = 0 Then AccessDataSource1.SelectCommand += String.Format(" ((Category = @Category OR 'Computer' ") AccessDataSource1.SelectCommand += String.Format(" OR 'Literature & Fiction' OR 'Reference'") AccessDataSource1.SelectCommand += String.Format(" OR 'Romance' OR 'Science'") AccessDataSource1.SelectCommand += String.Format(" OR 'Home Design' OR 'Accounting & Finance'") AccessDataSource1.SelectCommand += String.Format(" OR 'Horror' OR 'Refernce'))") Else AccessDataSource1.SelectCommand += String.Format("(( Category = @Category ))") End If For Each Item As ListItem In ListBox1.Items If Item.Selected = 0 Then AccessDataSource1.SelectCommand += String.Format(" AND ((Title Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR [Author(s)] Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR Publisher Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR ISBN Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR Price Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR Category Like @Search + '%'", Item.Text) AccessDataSource1.SelectCommand += String.Format(" OR Year Like @Search + '%' ))", Item.Text) End If If Item.Selected = 1 Then AccessDataSource1.SelectCommand += String.Format(" AND (Title Like @Search + '%' )", Item.Text) End If If Item.Selected = 2 Then AccessDataSource1.SelectCommand += String.Format(" AND ([Author(s)] Like @Search + '%' )", Item.Text) End If If Item.Selected = 3 Then AccessDataSource1.SelectCommand += String.Format(" AND (Publisher Like @Search + '%' )", Item.Text) End If If Item.Selected = 4 Then AccessDataSource1.SelectCommand += String.Format(" AND (ISBN Like @Search + '%' )", Item.Text) End If If Item.Selected = 5 Then AccessDataSource1.SelectCommand += String.Format(" AND (Price Like @Search + '%' )", Item.Text) End If If Item.Selected = 6 Then AccessDataSource1.SelectCommand += String.Format(" AND (Category Like @Search + '%' )", Item.Text) End If If Item.Selected = 7 Then AccessDataSource1.SelectCommand += String.Format(" AND (Year Like @Search + '%' )", Item.Text) End If Next Dim KeywordCom As String = AccessDataSource1.SelectCommand.ToString Context.Items("Test") = KeywordCom.ToString Server.Transfer("Result.aspx") End Sub </script> </head> <html> <body> <a href="Default.aspx">Home</a> <a href="About.aspx">About.aspx</a><a href="SearchResult.aspx">SearchResult.aspx</a> <form id="form1" runat="server"> <h3> Search for: <asp:TextBox ID="SearchBox" runat="server" Width="219px" /> <asp:Button ID="Button1" Text="Search" Width="146px" AccessKey="S" runat="server" Enabled="True" Onclick="Test" height="26px" style="position: relative"/> </h3> <h3> Search In:<asp:ListBox ID="ListBox1" runat="server" style="margin-left: 6px" Width="221px"> <asp:ListItem>Keyword Anywhere</asp:ListItem> <asp:ListItem>Title</asp:ListItem> <asp:ListItem>Author(s)</asp:ListItem> <asp:ListItem>Publisher</asp:ListItem> <asp:ListItem>ISBN</asp:ListItem> <asp:ListItem>Price</asp:ListItem> <asp:ListItem>Category</asp:ListItem> <asp:ListItem>Year</asp:ListItem> </asp:ListBox> </h3> <h3> Category: <asp:DropDownList ID="DropDownList" runat="server" Height="16px" Width="162px"> <asp:ListItem>All Categories</asp:ListItem> <asp:ListItem>Computer</asp:ListItem> <asp:ListItem>Literature & Fiction</asp:ListItem> <asp:ListItem>Reference</asp:ListItem> <asp:ListItem>Romance</asp:ListItem> <asp:ListItem>Science</asp:ListItem> <asp:ListItem>Home Design</asp:ListItem> <asp:ListItem>Accounting & Finance</asp:ListItem> <asp:ListItem>Horror</asp:ListItem> </asp:DropDownList> <asp:Button ID="Button3" runat="server" Text="Exit Store" Width="146px" height="26px" /> </h3> <p> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1" > <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="ISBN" HeaderText="ISBN" SortExpression="ISBN" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Author(s)" HeaderText="Author(s)" SortExpression="Author(s)" /> <asp:BoundField DataField="Publisher" HeaderText="Publisher" SortExpression="Publisher" /> <asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" /> <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /> <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" /> <asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select" ShowHeader="True" Text="Select" runat="server" /> </Columns> </asp:GridView> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Books.accdb" > <SelectParameters> <asp:ControlParameter Name="Category" ControlID="DropDownList" PropertyName="SelectedValue" /> <asp:ControlParameter Name="Search" ControlID="SearchBox" PropertyName="Text" /> <asp:ControlParameter Name="InColumn" ControlID="ListBox1" PropertyName="SelectedValue" /> </SelectParameters> </asp:AccessDataSource> </p> <p> </p> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </form> </body> </html>
I have a database that has names and months of birth. I would like to have a Choose Month: with a drop down menu to select the month of your choice, then have the results show in a gridview at the bottom of the page. I thought this would be fairly simple but my grid doesn't show anything.
I am new to visual studio .net c#. I was able to use Jdeveloper to create a search result page - search criteia on top with a "search" button, a result set table or form at the bottom of the page.
I have a Quick search box for a real estate website, which will search from the SQL server. I have two Radio buttons , and two dropdownlists. I want to display the result in a new page using the chosen criteria, I found this article but it's in VB, I want the code in C#. What i understad that i put this code for the search button:
i know how do the paging with normal return query using row number in sql server, but i'm looking how to do the paging , sql server full text search returning result.
Can i use the same row number function or any good perfomance way?
whcih sql server full text search(FREETEXT,CONTAINS and etc) is best article site?
I'm a complete novice in .NET. I am trying to implement a multi textbox / dropdowns / checkboxes search for a website using vb.net. How do I pass the values of my form fields to my griedview and display the search result on the same page?
I've written a stored procedure and specified it as data source for my gridview and defined parameter source as my CONTROLS (textboxes, checkboxes n dropdowns) on the form. What I want is when a user fills out one or multiple fields on the form, how do I display data in the gridview on the click of SEARCH button? Also is it necessary to write a codebehind for my search button or we can achieve the desired result in some other way?
i am working with search page .. when i click the search button it will show some result like google.. when i click url it will show some personal information. But my problem is i will store data in line line by format. like our forms . but it will display only one single line as page width.. how can i store data in database like that and how can i get that data like to display what i am putting in textbox like this forms
Let's say I have a gridview with some columns like, title, name, funding agency. Here's an example of what I want to do:
I want to display all the records in the gridview to start. There would be a dropdownlist that lets the user select whether to search by title, name, funding agency and a text box that lets them type in what they want to search for (and a button to start the search). After searching, the gridview would only display the records that matched the criteria.i already know how to connect datasets to the gridview, but i am using mysql database and writing code in vb.how to accomplish this task
hope you guys are doing well! I have a question and no answer yet how to do it. Right now i can have 1 dropdownlist and when i press on my search button its show the result of the query the user ask
but how to do it with two seperates dropdownlist ? isnt it with inner join ? also if the value is null what to do ?
I have one left side panel which containg one search box and treeview, when user type any search text than i have to dropdown the list of matching item below textbox,according to search text user can able to find text on dropdown, when user select particular text and click on same on treeview that text would be automated selected and on right side panel data will pupulate automatically according to selected item.same like
I have atable for video files contains the following fieldsIDTitleDescriptionImageViewsUserCategoryI have a text box in the currency ofthe burden of private research is showing results in another page I called it asearch resultFirst of all, has a store of the research processso
[Code]....
'd Like to getthe results in the Grid viewAnd the results are imageany onecan tell me how to make my photo show and control of size in order to become like YouTube
* Products table, it is consists of these columns :
ProductId int
ProductNO nvarchar
CatalogeId int
BrandId int
MainSpecification nvarchar
DetailsSpecification ntext
Image imageand I want to desgin form for products, and this form contain these ToolBox
* DropDownList for CatalogeId
* DropDownList for BrandId
* DataList Control for displaying the Result Search
* Button
When the user visit Product Page for Example (productpage.aspx), then he see the two DropDownList , then choose one of Cataloge Name (Laptop , Printer, ....) , and choose one of the Brand Name (Sony, Toshiba, ....) , then Click the Button, and get the Result Search in Paging DataList
I'm about to create a masterpage that contains a search field, the result from the search should be placed inside a contentplaceholder, but how do I build that? I added the search form to the masterpage (not inside a contentplaceholder), and then I added the eventhandler for the button that trigger the search. Now lest say I want to display the result in the contentplaceholder, how would I do that?
I have two tables --- Table1 has an identity column ID and a team name column and Table2 has columns where one column is one team's ID# and another column with the second teams ID# and other columns with scores for each team for that week.want to do a query to show that week's result but instead of the ID#, show the teams' names.
I have a user controlThe user selects some items from user control (check box list)User clicks update button on user control The new rows get updated on a gridview on calling page & user control is hidden
a)I have made the user control but I dont know how to return the results and bind them with gridview on my calling page.
b) Update: If I create the update button outside the user control and on my calling page and then on its button click event Isomehow access user control checkbox list selected items would that be a good approach ? And how to do this stuff ?
Basically I want to have a page do a search on first name(textbox), last name(textbox), gender(dropdown). and return a grid result back. it's so easy in web forms. how do i do in mvc? So far I have: Controller
[Code]....
View: Search.aspx
[Code]....
I didn't modify the route. When I put in [URL], it says resource not found.
I have data list in mypage and i have table in my DB that have 30 row with data
I want my datalist just show 10 row of my Table in 5 column i set Repeat column=5 for my datalist but i don't know how i can set that show just 10 row of my table from my data base
i dont need other row i just want show 10 row that i define in my procedure ...
I have an ASP .NET web application. I'm fairly new to .Net but a longtime SQL and Java programmer. I have a requirement to implement a search feature as it is currently implemented in the legacy application. There is a pageable grid of data displayed and a search box. You type your search criteria and the grid pages to the first match. A "next match" button pages to the next item etc. This way the user sees where their search item falls in the hierarchy of the data. I have seen examples where the search criteria filters the data, limiting the data results.
I've been implementing MS Search Server 2010 and so far its really good. Im doing the search queries via their web service, but due to the inconsistent results, im thinking about caching the result instead.
The site is a small intranet (500 employees), so it shouldnt be any problems, but im curious what approach you would take if it was a bigger site.
I've googled abit, but havent really come over anything specific. So, a few questions:
What other approaches are there? And why are they better?
How much does it cost to store a dataview of 400-500 rows? What sizes are feasible?