Need help with Hidden Fields

Hi,

I have a page in which I get 100's of rows from a DB Table and display them on the page. I want to set it so that when I click on a row, it sends you to another page with more details on that item. I THOUGHT I could do this by putting the ID for each item into hidden fields, but I'm having a tough time getting the Hidden Field value out of the form when I click a row. If I view source, it shows my hidden field values as accurate, but I just can't get the right code (Javascript or otherwise) to get a hold of this data.

Thanks

Comments

  • : Hi,
    :
    : I have a page in which I get 100's of rows from a DB Table and display them on the page. I want to set it so that when I click on a row, it sends you to another page with more details on that item. I THOUGHT I could do this by putting the ID for each item into hidden fields, but I'm having a tough time getting the Hidden Field value out of the form when I click a row. If I view source, it shows my hidden field values as accurate, but I just can't get the right code (Javascript or otherwise) to get a hold of this data.
    :
    : Thanks
    :

    You can use HTML objects within your web forms in ASP.NET. But you have to identify HTML object as a server control.It could be a HTML table,row or hidden area etc.

    In VS go to web form's HTML view and add this line



    then press Ctrl-pgUp so hidden control description is added your code behind automatically by VS.Now you can use hidden value within your code behind.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Response.Redirect("details.aspx?id="+me.hdnid.value.tostring)
    End Sub



    Ismail Cem AKSOY
    Web Developer,MCAD

  • First-off, I would consider using one of these data web controls that come w/ ASP.NET:

    DataGrid (ASP.NET 1.0-1.1)
    GridView (ASP.NET 2.0)
    Repeater
    DataList

    All these controls can render your data in an HTML table fashion. The DataGrid and DataList controls have a DataKeyField that you set to the name of the id-column in your datasource. When you click on an asp.net button w/ in one of the DataGrid and DataList rows an ItemCommand event is fired. Inside this event you then read from the DataKeys property to get the id for the current row:

    [code]
    private Sub myGrid_ItemCommand(ByVal sender As Object, ByVal e As DataGridEventArgs) Handles myGrid.ItemCommand
    Dim id As Integer = myGrid.DataKeys(e.Item.ItemIndex)

    Response.Redirect("otherPage.aspx?id=" & id)
    End Sub
    [/code]

    : Hi,
    :
    : I have a page in which I get 100's of rows from a DB Table and display them on the page. I want to set it so that when I click on a row, it sends you to another page with more details on that item. I THOUGHT I could do this by putting the ID for each item into hidden fields, but I'm having a tough time getting the Hidden Field value out of the form when I click a row. If I view source, it shows my hidden field values as accurate, but I just can't get the right code (Javascript or otherwise) to get a hold of this data.
    :
    : Thanks
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories