Add a hidden value to a <asp:button>

Results 1 to 2 of 2

Thread: Add a hidden value to a <asp:button>

  1. #1
    Join Date
    Dec 1969

    Default Add a hidden value to a <asp:button>

    In ASP when I created a Edit or Delete button I would create a form with a hidden value that was the Database Primary Key. I could then use a Request.Form to get the value to populate my SQL statement to pull out that specific record.<BR><BR>I&#039;m looking to accomplish the same thing in ASP.Net with out using a DataGrid. I think a DataGrid will accomplish this but I don&#039;t have a grasp on the DataGrid and the little I do know looks like it is hard to control the DataGrid.<BR><BR>I&#039;m using a DataReader to loop through all of the records from the DB. I was going to make a form for the Edit or Delete button but I don&#039;t know how to pass along the database primary key. <BR><BR>Can someone give me an example of how to do this and maybe an example of the code I would use on the codebehind page to retreive the value to populate a SQL statement.<BR><BR>Thanks,<BR>David

  2. #2
    Join Date
    Dec 1969

    Default RE: Add a hidden value to a <asp:button>

    There must be many ways to do this. This is what I usually do:<BR><BR>When the user presses the button. The code behind the button must save the selected primary is a Session variable like this:<BR>Session("selectedId") = ...<BR><BR>You can retrieve the value like this<BR>Dim myId as string = Session("selectedId").ToString<BR><BR>Good luck.<BR><BR>Ultima

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts