Results 1 to 5 of 5

Thread: Formatting RSS Columns in a datagrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Formatting RSS Columns in a datagrid

    I have an ASP.Net news reader where I syndicate news items from different sites. In my current app I am just streaming the XML and using a XSL file to format the look of the feed.

    As an alternative I want to pull the RSS files and parse them with a datagrid like this. The problem I am having is that I don't know how to remove columns I don't want in the grid specificaly the redundant title and the channel id.

    Here is the datagrid (without formatting):
    Code:
    <asp:DataGrid id="rss" runat="server">
     <Columns>
       <asp:TemplateColumn HeaderText="New Items">
         <ItemTemplate>
          <a href="<%# DataBinder.Eval(Container.DataItem, "link")%>"> 
          <%# DataBinder.Eval(Container.DataItem, "title") %></a> 
         </ItemTemplate>
       </asp:TemplateColumn>
     </Columns>
    </asp:DataGrid>
    Any ideas?

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    I did a project similar to that. What I did was use a DataList instead of DataGrid. I then put 2 labels and a hyperlink control in the DataList, then binded those controls to the columns in the Rss Feeds that I wanted to display.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Try including this:
    AutoGenerateColumns="False"

    Example:
    <asp:DataGrid id="rss" runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn HeaderText="New Items">
    <ItemTemplate>
    <a href="<%# DataBinder.Eval(Container.DataItem, "link")%>">
    <%# DataBinder.Eval(Container.DataItem, "title") %></a>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    Thanks to both of you for answering my question. Hellswraith that worked perfectly and even worked out a little better then I imagined.

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    The AutoGenerateColumns always messes me up until I go turn it to false. Sometimes my result set contains a lot more columns than what I want displayed, so I always turn it off and specify the columns that I want shown.

    Glad to hear that it works. Good luck.

Posting Permissions

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



Click Here to Expand Forum to Full Width