Subject: Hyperlinks in a grid
Posted By: Louisa Post Date: 8/11/2005 9:31:46 AM
I have a datagrid with various details of contractors, I would like to have the column containing the contractors names to be hyperlinks to link to a form containing the contractors full details. How do I do this as I don't want to further buttons in the grid.

Thanks

Louisa

Reply By: s.hendy Reply Date: 8/11/2005 10:52:34 AM
Hi Louisa

I'm no expert, but assuming your have AutoGenerateColumns="false" within the datagrid, you would then set up a column, with something like the following:

<columns>
  <asp:TemplateColumn HeaderText="Contractor">
    <itemtemplate>
        <a href="[formpage].aspx?id=('<%# DataBinder.Eval(Container.DataItem, "[contractorID_Field]") %>');"><%# DataBinder.Eval(Container.DataItem, "[contractorName_Field]") %></a>
  </itemtemplate>
</asp:TemplateColumn>

Without knowing what your database field names are, it's hard to map them above, and also, without knowing how you want to link them, ie, is it one form page which is populated based on the contractor (in which case you could send the contractorID to that form page and use a Request.QueryString on the form page to get it, or have you got multiple pages, ie, one for each contractor?

Reply By: jbenson001 Reply Date: 8/14/2005 12:26:11 AM
Add a hyperlink column to your grid using the Property Builer, then set the various properties there.

Reply By: Louisa Reply Date: 8/15/2005 4:18:28 AM
Hi

I continued to alter the code and it now works brilliantly thanks very much for you help

Louisa


Go to topic 33834

Return to index page 490
Return to index page 489
Return to index page 488
Return to index page 487
Return to index page 486
Return to index page 485
Return to index page 484
Return to index page 483
Return to index page 482
Return to index page 481