search function + accordion

Last post 07-26-2009 11:03 PM by chetan.sarode. 3 replies.

Sort Posts:

  • search function + accordion

    07-24-2009, 3:25 PM
    • Member
      9 point Member
    • lm111
    • Member since 07-24-2009, 7:11 PM
    • Posts 35

    Hello,

    Based on this small sample below, could I use an Accordion instead of the GridView? I can't figure it out. Thanks a lot.


    <%@ Page Language=”C#” %>
    <%@ Import Namespace=”System.Data” %>
    <%@ Import Namespace=”System.Data.SqlClient” %>
    <%@ Import Namespace=”System.Web.Configuration” %>

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <script runat=”server”>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
    // Get movies DataTable from Cache
    DataTable dtblMovies = (DataTable)Cache[“MoviesToFilter”];
    if (dtblMovies == null)
    {
    dtblMovies = GetMoviesFromDB();
    Cache[“MoviesToFilter”] = dtblMovies;
    }
    // Select matching rows
    string filter = String.Format(“Title LIKE ‘{0}*’”, txtTitle.Text);
    DataRow[] rows = dtblMovies.Select(filter, “Title”);
    // Bind to GridView
    grdMovies.DataSource = rows;
    grdMovies.DataBind();
    }
    private DataTable GetMoviesFromDB()
    {
    string connectionString = WebConfigurationManager.ConnectionStrings[“Movies”].ConnectionString;
    SqlDataAdapter dad = new SqlDataAdapter(“SELECT Title, Director FROM Movies”, connectionString);
    DataTable dtblMovies = new DataTable();
    dad.Fill(dtblMovies);
    return dtblMovies;
    }
    </script>
    <html xmlns=”http://www.w3.org/1999/xhtml” >
    <head id=”Head1” runat=”server”>
    <style type=”text/css”>
    th, td
    {
    padding:5px;
    }
    </style>
    <title>Show DataTable Select</title>
    </head>
    <body>
    <form id=”form1” runat=”server”>

    <div>
    <asp:TextBox id=”txtTitle” Tooltip=”Search” Runat=”server” />

    <asp:Button id=”btnSearch” Text=”Search” Runat=”server” OnClick=”btnSearch_Click” />
    <hr />


    <asp:GridView id=”grdMovies” AutoGenerateColumns=”false” Runat=”server”>
    <Columns>
    <asp:TemplateField HeaderText=”Title”>
    <ItemTemplate>
    <%# ((DataRow)Container.DataItem)[“Title”] %>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText=”Director”>
    <ItemTemplate>
    <%# ((DataRow)Container.DataItem)[“Director”] %>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </div>
    </form>
    </body>
    </html>

  • Re: search function + accordion

    07-24-2009, 4:38 PM
    • Participant
      1,537 point Participant
    • PNasser
    • Member since 04-13-2009, 4:04 PM
    • Posts 276

     I could be missing something, but the Accordian is usually for visual styling of an element of some type, you have the header bar, which expands and collapses the content area below it (or to the side of it).

    The gridview is for showing multiple records.

    You could put the gridview inside of an accordian (completely up to you - nobody can say it's right or wrong). If you're asking if each row should be in it's own accordian, probably not.

    ~P

  • Re: search function + accordion

    07-24-2009, 11:38 PM
    • Participant
      1,398 point Participant
    • Sayre
    • Member since 07-24-2008, 5:03 AM
    • Manila, Philippines
    • Posts 349

     Hi,

    Accordion is an ajax component that you can hide, show a content with animated transition between content.

    If you have data result from your query in database, if you want to see it to your application thats the time you will use a gridview.

     

    Please clarify your question about accordion.

    Hope This One Can Help.
    Thanks

    To Be Happy Is To Be YourSelf

    codeincsharp.blogspot.com
  • Re: search function + accordion

    07-26-2009, 11:03 PM
    Answer

     You are binding the data to GRidView and displaying it

    The Accordion is a web control that allows you to provide multiple panes and display them one at a time. It is like having several CollapsiblePanels where only one can be expanded at a time.

    http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Accordion/Accordion.aspx

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
Page 1 of 1 (4 items)