Romacali
asked on
PostBackUrl with a ID attached to it
Hi,
On my gridview I have a row that has an imagebutton that should take to my evaluationpage.. the problem is that I have no clue how to post the participantID
like this:
PostBackUrl="~/SurveyData/ evaluation .aspx?r=Pa rticiapntI D" ParticiapntID = int
I've tried this:
<asp:ImageButton ID="lnkSelect2" PostBackUrl='evaluation.as px?r=<% eval(ParticipantID) %>' runat="server" ImageUrl="~/Images/icons/p encil.gif" ToolTip="Edit Evaluation" />
and I got this on the url: /evaluation.aspx?r=%3C%Par ticipantID %%3E
any idea?
On my gridview I have a row that has an imagebutton that should take to my evaluationpage.. the problem is that I have no clue how to post the participantID
like this:
PostBackUrl="~/SurveyData/
I've tried this:
<asp:ImageButton ID="lnkSelect2" PostBackUrl='evaluation.as
and I got this on the url: /evaluation.aspx?r=%3C%Par
any idea?
Try using eval(HttpUtility.HTMLDecod e(Particip antID))
Actually, disregard my previous post. I didn't read your question closely enough.
As per my understanding, the code for handling postbacks from the controls within GridView are handled within RowCommand event mostly although there are specific events available for editing, deleting, etc.
With the RowCommand event of the GridView, write the following code.
1. You have to set the CommandName and CommandArguemnt properties of the ImageButton. CommandName can be set at design time whiel CommandArgument must be set at Runtime.
2. Make use of DataKeyNames property of the GridView and set its value to ParticipantID which actually is your row-key. This is utilized for setting CommandArguemnt on ImageButton within RowDataBound event.
3. Finally, within RowCommand, read the value of CommandArguement and do as necessary.
With the RowCommand event of the GridView, write the following code.
1. You have to set the CommandName and CommandArguemnt properties of the ImageButton. CommandName can be set at design time whiel CommandArgument must be set at Runtime.
2. Make use of DataKeyNames property of the GridView and set its value to ParticipantID which actually is your row-key. This is utilized for setting CommandArguemnt on ImageButton within RowDataBound event.
3. Finally, within RowCommand, read the value of CommandArguement and do as necessary.
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
CType(e.Row.Cells(0).FindControl("btnDoSomething"), ImageButton).CommandArgument = GridView1.DataKeys(e.Row.RowIndex).Values(0).ToString()
End If
End Sub
Private Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "DoSomething" Then
Dim intParticipantId As Integer = CInt(e.CommandArgument)
'Do anything you wish to do there
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.