Solved

PostBackUrl with a ID attached to it

Posted on 2009-05-14
6
756 Views
Last Modified: 2013-12-17
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=ParticiapntID"   ParticiapntID = int

I've tried this:
<asp:ImageButton ID="lnkSelect2" PostBackUrl='evaluation.aspx?r=<% eval(ParticipantID) %>' runat="server" ImageUrl="~/Images/icons/pencil.gif" ToolTip="Edit Evaluation"  />
and I got this on the url: /evaluation.aspx?r=%3C%ParticipantID%%3E


any idea?
0
Comment
Question by:Romacali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:ViceroyFizzlebottom
ID: 24390519
Try using eval(HttpUtility.HTMLDecode(ParticipantID))
0
 
LVL 6

Expert Comment

by:ViceroyFizzlebottom
ID: 24390528
Actually, disregard my previous post. I didn't read your question closely enough.
0
 
LVL 11

Expert Comment

by:Muhammad Ousama Ghazali
ID: 24390566
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.

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

Open in new window

0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 200 total points
ID: 24390594
Sorry I posted the code with VB. Check the code below:
//RowDataBound event code
if (e.Row.RowType == DataControlRowType.DataRow)
{   
    ((ImageButton)e.Row.Cells(0).FindControl("btnDoSomething")).CommandArgument = GridView1.DataKeys(e.Row.RowIndex).Values(0).ToString();
}
 
//RowCommand evnet code
if (e.CommandName == "DoSomething")
{
    int intParticipantId = (int)e.CommandArgument;
    //Do anything you wish to do there
}

Open in new window

0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 100 total points
ID: 24391589
before i can answer i will like to ask another question
what is your exeact requirement of doing this

i think that you want to capture the ParticiapntID on the server side when you click on the gridview row
if i am correct then use the feature of datakeynames by setting it to participant id and then on the server side you can get the value back

set datakeyfield for gridview
<asp:GridView ID="grdview1" datakeynames="ID" ------>

while editing u can retrive id like this
string Id = grdview1.DataKeys[e.Row.RowIndex].Value.ToString();
0
 
LVL 2

Assisted Solution

by:phead_2
phead_2 earned 200 total points
ID: 24391850
PostBackUrl='<%# "~/SurveyData/evaluation.aspx?r=" + Eval("ParticapantID").ToString() %>'


0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question