GridView newbie

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

Hello, I have a Gridview bound to a data source that has a query like this:

select Title, ID from TitleList

I just want to display one column. It should have a link in it that
goes something like this (if I were to create this link in c# code)

<a href="title.aspx?id=" + ID.ToString() + ">" + Title + "</a>

I tried playing around with template fields but i am totally new to
this, so I am running up against a wall.

Thanks.
 
Hi Frank,

Check out this article for the GridView control:
http://msdn.microsoft.com/msdnmag/issues/04/08/GridView/

There, you will find the thing that you are trying to do in the section
"Displaying, Sorting, and Paging". However, I will recommend reading the
whole article, because it really gives good foundation for the GridView
control.

Regards,
George Jordanov Ivanov
 
Example for datagrid in 1.1. Haven't done it yet with a gridview, but
it should be about the same...

private void grdMessage_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) || ((e.Item.ItemType ==
ListItemType.AlternatingItem)))
{
e.Item.Cells[0].Text = "<a href='Somepage.aspx'
target='_blank'>" + e.Item.Cells[2].Text + "</a>";
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top