This is a migrated thread and some comments may be shown as answers.

[Solved] hyperlinked grid item

2 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan Davis
Top achievements
Rank 1
Bryan Davis asked on 15 Oct 2009, 05:34 PM

Hello I have a little issue here.  I am trying to link an item in my grid via its id but at the same time displaying its name instead.  Basiclay I have items in my sql table with names like IBM, NRC, and so on, each one has its unique id.  While I did manage to get this querystring to work I have to use an additional hyerlinked column.  I want to use just the name to link to the next page.   Thank you,

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:harwoodConnectionString %>"
            SelectCommand="SELECT  top 3 [NewsArticleID], [NewsArticleName] FROM [NewsArticles]
order by enddate desc"></asp:SqlDataSource>
        <telerik:RadGrid ID="RadGrid1" runat="server" Skin="" DataSourceID="SqlDataSource1" GridLines="None" ShowHeader="false">
            <HeaderContextMenu EnableTheming="True">
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            </HeaderContextMenu>
            <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                <telerik:GridBoundColumn  DataField="NewsArticleName" 
                        HeaderText="NewsArticleName" SortExpression="NewsArticleName" 
                        UniqueName="NewsArticleName">
                    </telerik:GridBoundColumn>
                    <telerik:GridHyperLinkColumn ItemStyle-HorizontalAlign="Right" DataTextFormatString="   read more..." DataNavigateUrlFields="NewsArticleID"
                        UniqueName="NewsArticleID" DataNavigateUrlFormatString="~/NewsArticle.aspx?NewsArticleID={0}"
                        DataTextField="NewsArticleID">
                    </telerik:GridHyperLinkColumn>
                </Columns>

2 Answers, 1 is accepted

Sort by
0
Accepted
Thomas Salt
Top achievements
Rank 1
answered on 15 Oct 2009, 05:51 PM
Change your
DataTextField="NewsArticleID"
to
DataTextField="NewsArticleName"
in your GridHyperLink Column.

0
Bryan Davis
Top achievements
Rank 1
answered on 15 Oct 2009, 06:12 PM
I had to remove the "DataTextFormatString=" read more..."  as well, but your answer pointed me in the right direction.  Thanks for your help.
Tags
Grid
Asked by
Bryan Davis
Top achievements
Rank 1
Answers by
Thomas Salt
Top achievements
Rank 1
Bryan Davis
Top achievements
Rank 1
Share this question
or