how do I get the value of a post from a hidden field in repeater?

Discussion in 'ASP .Net' started by Kevin, Feb 25, 2004.

  1. Kevin

    Kevin Guest

    I've got a problem where I need to know the value of a hidden field
    inside a repeater once a button is clicked. Ths code inside my
    repeater looks like this:

    <input id="conf_num" type="hidden" value=<%#
    trim(Container.DataItem("confirm_num"))%> name="conf_num"
    runat="server" />

    <asp:ImageButton ImageUrl="images/send_conf.gif"
    OnClick="ConfSend_Click" runat="server" />

    Rendered, it looks like this:

    <input name="grid3:_ctl1:conf_num" id="grid3__ctl1_conf_num"
    type="hidden" value="551059" />

    Obviously, I can get the value if I do something like:

    Sub ConfSend_Click
    ViewState("conf_num") = Request.form("grid3:_ctl1:conf_num")
    End Sub

    But this doesn't work because to do this right I can't specify the
    exact Request.form 'conf_num' value, since that value needs to be
    dynamic based on the button the user clicks on. I've tried
    everything, I think. Each row in the repeater has its own button...

    What happened to the good old days when a hidden field was a hidden
    field. The 'grid3:_ctl1:' the rendered repeater adds on is giving me
    major problems.

    Any ideas?
    Kevin, Feb 25, 2004
    #1
    1. Advertising

  2. Kevin

    Raterus Guest

    Look at the commandname/commandargument properties of the imagebutton, you
    can set them to anything you want. Then use the onCommand (not onClick)
    event of the imagebutton to catch them on the next page. In your handler
    e.CommandName and e.CommandArgument would be from the button you clicked.
    Doing this you can avoid all the mess of using hidden fields.

    Hope this helps,
    --Michael

    "Kevin" <> wrote in message
    news:...
    > I've got a problem where I need to know the value of a hidden field
    > inside a repeater once a button is clicked. Ths code inside my
    > repeater looks like this:
    >
    > <input id="conf_num" type="hidden" value=<%#
    > trim(Container.DataItem("confirm_num"))%> name="conf_num"
    > runat="server" />
    >
    > <asp:ImageButton ImageUrl="images/send_conf.gif"
    > OnClick="ConfSend_Click" runat="server" />
    >
    > Rendered, it looks like this:
    >
    > <input name="grid3:_ctl1:conf_num" id="grid3__ctl1_conf_num"
    > type="hidden" value="551059" />
    >
    > Obviously, I can get the value if I do something like:
    >
    > Sub ConfSend_Click
    > ViewState("conf_num") = Request.form("grid3:_ctl1:conf_num")
    > End Sub
    >
    > But this doesn't work because to do this right I can't specify the
    > exact Request.form 'conf_num' value, since that value needs to be
    > dynamic based on the button the user clicks on. I've tried
    > everything, I think. Each row in the repeater has its own button...
    >
    > What happened to the good old days when a hidden field was a hidden
    > field. The 'grid3:_ctl1:' the rendered repeater adds on is giving me
    > major problems.
    >
    > Any ideas?
    Raterus, Feb 25, 2004
    #2
    1. Advertising

  3. thanks - worked like a charm.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Kevin McGovern, Feb 25, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xenophon

    Hidden Form Field Value Get?

    xenophon, Dec 9, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    28,588
  2. Rick
    Replies:
    3
    Views:
    8,092
    Alexey Smirnov
    Apr 13, 2010
  3. GavMc
    Replies:
    4
    Views:
    310
    Evertjan.
    Sep 22, 2005
  4. Rauf ul Hassan

    Post a hidden field value

    Rauf ul Hassan, Aug 20, 2003, in forum: Javascript
    Replies:
    1
    Views:
    132
    Andy Fish
    Aug 20, 2003
  5. Replies:
    6
    Views:
    201
Loading...

Share This Page