SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pulling .NET Dynamic Data by First Letter only

    Hi everyone,

    I have a long list of dynamic data being generated on a jquery mobile site. I'd like to have this data be separated by alphabet list bars, much like the directory organization of a phone by first letter. (ex: jQuery Mobile: Demos and Documentation)

    Another option would simply be to only call the data by first letter. For example, I select the letter "A", and all the data that starts with "A" displays.

    I am calling names via ASP.NET.vb repeated method with: <%# Eval("Name")%>

    That code of course pulls all names. How can I narrow it down to specific letter starts? I am new to ASP and ASP.NET; therefore, I'm not quite sure where to start or what terminology to start researching. Any help would be greatly appreciated, thank you.

  2. #2
    SitePoint Guru pufa's Avatar
    Join Date
    Oct 2004
    Location
    Portugal, Lisboa
    Posts
    947
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where is the data coming from? In what type... plain old ado.net (DataTables, DataReader), web service, linq to *, file ...

    linq is great for this type of stuff.

    select foo from bar where foo.Name.StartsWith("A");

    SQL
    "SELECT * FROM FOO WHERE NAME LIKE @p" with @p = 'A%'
    Ciao, Rui...

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help pufa,

    I am pulling content from a Microsoft SQL database.
    It is just being read via a Repeater.
    My current set up can be seen below:
    What do you think?
    I appreciate your help.

    Code:
    <div data-role="collapsible-set">
    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1">
    <ItemTemplate>
    <div data-role="collapsible" data-collapsed="true">
        <h3><%# Eval("Name")%></h3>
        <p>Room: <%# Eval("Room")%></p>  
    </div>
    </ItemTemplate>
    </asp:Repeater>
    </div><!-- /collapsible set-->

  4. #4
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    You must be using sql statement in your SqlDatasource1. If so or no, try using "SELECT Name, Room FROM [your table] WHERE NAME LIKE 'A%' ". Later, you can replace your SQL with dynamic value for 'A', 'B' etc. Do not fetch all the data from database and filter on client side.
    Providing full source can be of much help.

    Thanks
    Raman Basu


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •