?
Solved

PostBackUrl with a ID attached to it

Posted on 2009-05-14
6
Medium Priority
?
762 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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 800 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 400 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 800 total points
ID: 24391850
PostBackUrl='<%# "~/SurveyData/evaluation.aspx?r=" + Eval("ParticapantID").ToString() %>'


0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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