Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A datagrid control with a ‘HyperLinkColumn’ 1

Status
Not open for further replies.

cesark

Programmer
Dec 20, 2003
621
I am loading a page with a datagrid control that contains a ‘HyperLinkColumn’, thus:

Code:
<asp:datagrid ID="offers_list" AutoGenerateColumns="false"
	   AllowPaging="true" AllowCustomPaging="true" PageSize="20" PagerStyle-Visible="false"
	   HeaderStyle-CssClass="letter3" HeaderStyle-BackColor="#FFFFFF" HeaderStyle-Height="25" HeaderStyle-VerticalAlign="bottom"
	   AlternatingItemStyle-BackColor="#FFFFFF" CssClass="tableResults"
	   BackColor="#ECF1E2" ItemStyle-Height="30" GridLines="None" runat="server">

       <Columns>
            <asp:BoundColumn DataField="theDate" HeaderText="Date" SortExpression="Date" DataFormatString="{0:d}" ItemStyle-Width="85"> 
              <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
              <ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:BoundColumn>			
			[b]<asp:hyperlink DataTextField="Company_name" HeaderText="Company" ItemStyle-Width="250" DataNavigateUrlField="Company_num"   DataNavigateUrlFormatString="detail_company.aspx?id={0}"></asp:hyperlink>[/b]
            <asp:BoundColumn DataField="Offer_title" HeaderText="Offer Title" ItemStyle-Width="425"> 
            </asp:BoundColumn>
            <asp:BoundColumn DataField="City_name" HeaderText="City" ItemStyle-Width="125"> 
            </asp:BoundColumn>
       </Columns>
			
</asp:datagrid>

And when I load the page I receive this error:

Parser Error Message: System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'asp:hyperlink' is of type 'System.Web.UI.WebControls.HyperLink'.

Line 182: <asp:hyperlink DataTextField="Company_name" HeaderText="Company" ItemStyle-Width="250" DataNavigateUrlField="Company_num” DataNavigateUrlFormatString="detail_company.aspx?id={0}"></asp:hyperlink>


But.. HyperLinkColumn isn’ t a column type of DataGrid control?

Thank you,
Cesar
 
Try adding it as a HyperLinkColumn as opposed to a hyperling. e.g.
Code:
<asp:HyperLinkColumn ...

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
It is true, I didn' t realize it.. Now it works :)

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top