Results 1 to 3 of 3

Thread: [RESOLVED] basic datagrid question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Resolved [RESOLVED] basic datagrid question

    I'm just starting with datagrids.

    I have to make a list of items. Each item will have a link. But I want the link of the item to have a custom value, not present in the dataset as an item.

    All the essays I've found about asp.net, end up with:

    datagrid.datasource = dataset
    datagrid.databind()

    Now, I need to add custom values to that link, ex: default.aspx?dsRow=4 , where the dsrow is the number of the row in the dataset.

    How could I do that?

    Thanks for reading,
    HoraShadow

    PS: I'm not double posting. I posted in the vb.net forum by mystake.
    Last edited by HoraShadow; Jun 25th, 2005 at 04:02 PM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: basic datagrid question

    You can loop through the items in the ItemDataBound event. Here is a snippet from a page I'm working on:

    VB Code:
    1. Private Sub dgAddDeleteEmployees_ItemDataBound1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgAddDeleteEmployees.ItemDataBound
    2.  
    3.         If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
    4.             e.Item.Cells(2).Text = "<a class=""dgLinks"" href=""" & "EmployeeDetails.aspx?login=" & dt.Rows(e.Item.ItemIndex).Item("LoginId").ToString() & "&EmpName=" & dt.Rows(e.Item.ItemIndex).Item("EmpName").ToString() & "&Email=" & dt.Rows(e.Item.ItemIndex).Item("EmpMail").ToString() & """>" & Edit & "</a>"
    5.         End If
    6.  
    7.     End Sub

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: basic datagrid question

    Nice one!

    Thanks mendhak.

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