473,770 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Suggestion

Greetings,

My app displays users in a GridView control. I'd like to have the name field
shown in each row of this control a link that displays another page with
information about that user.

But I'm not sure how to approach this. How would I tell the target page
which user to display? I'd prefer not to pass the user's ID on the URL, and
I don't know when I'd get a chance to set a Session variable.

I know I can add a template with a link but, if I set an event handler for
that link, how does it know which row was selected?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Dec 31 '07 #1
9 1414
One way is to do Server.Transfer to the user info page on server side.

The link on the grid will fire just a postback, perhaps a RowCommand event,
the server will find what row fired the event, get the user id from the row,
put it in a session variable and transfer to the info page.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:O5******** ******@TK2MSFTN GP04.phx.gbl...
Greetings,

My app displays users in a GridView control. I'd like to have the name
field shown in each row of this control a link that displays another page
with information about that user.

But I'm not sure how to approach this. How would I tell the target page
which user to display? I'd prefer not to pass the user's ID on the URL,
and I don't know when I'd get a chance to set a Session variable.

I know I can add a template with a link but, if I set an event handler for
that link, how does it know which row was selected?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Jan 1 '08 #2
I've got a couple of ways to bring up another page. But, again, my issue is
providing the ID of the row the link was on.

So I couldn't quite follow your suggestion. Are you talking about built-in
row buttons, or something added via a template, or something else entirely?

That'd be a big help if you could clarify.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:ev******** ******@TK2MSFTN GP04.phx.gbl...
One way is to do Server.Transfer to the user info page on server side.

The link on the grid will fire just a postback, perhaps a RowCommand
event, the server will find what row fired the event, get the user id from
the row, put it in a session variable and transfer to the info page.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:O5******** ******@TK2MSFTN GP04.phx.gbl...
>Greetings,

My app displays users in a GridView control. I'd like to have the name
field shown in each row of this control a link that displays another page
with information about that user.

But I'm not sure how to approach this. How would I tell the target page
which user to display? I'd prefer not to pass the user's ID on the URL,
and I don't know when I'd get a chance to set a Session variable.

I know I can add a template with a link but, if I set an event handler
for that link, how does it know which row was selected?

Thanks for any tips.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Jan 1 '08 #3
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:ev******** *****@TK2MSFTNG P03.phx.gbl...
So I couldn't quite follow your suggestion. Are you talking about built-in
row buttons, or something added via a template, or something else
entirely?
http://msdn2.microsoft.com/en-us/lib...lectedrow.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 1 '08 #4
Am I completely up in the night here, or is that "selected row" business
restricted to gridviews that have a select button?

I want a link for each row (preferrably a hyperlink in actual data) to
direct the user to another page, and to somehow tell that page which row the
link was clicked on. There would be no separate step of selecting a row.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:Od******** ******@TK2MSFTN GP03.phx.gbl...
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:ev******** *****@TK2MSFTNG P03.phx.gbl...
>So I couldn't quite follow your suggestion. Are you talking about
built-in row buttons, or something added via a template, or something
else entirely?

http://msdn2.microsoft.com/en-us/lib...lectedrow.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jan 2 '08 #5
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:Oi******** ******@TK2MSFTN GP04.phx.gbl...
is that "selected row" business restricted to gridviews that have a select
button?
No.
I want a link for each row (preferrably a hyperlink in actual data) to
direct the user to another page, and to somehow tell that page which row
the link was clicked on. There would be no separate step of selecting a
row.
There are several ways you could do this...

Since you don't fancy the SelectedRow method, why not create a
TemplateColumn and add a LinkButton to it...? An asp:LinkButton is a button
control which looks like a hyperlink. This means that you can set its
CommandArgument value during the RowBinding of the GridView which you can
use to set a Session variable when the hyperlink is clicked, and then do a
Response.Redire ct to the other page:
http://msdn2.microsoft.com/en-us/lib...dargument.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 2 '08 #6
Mark,
>is that "selected row" business restricted to gridviews that have a
select button?

No.
I don't understand how can there be a selected row if a grid has no means to
select one?
Since you don't fancy the SelectedRow method, why not create a
Given my lack of knowledge on it, I have nothing against the SelectedRow
method. It's just that I'm not seeing how that would produce the effect that
I want.
TemplateColumn and add a LinkButton to it...? An asp:LinkButton is a
button control which looks like a hyperlink. This means that you can set
its CommandArgument value during the RowBinding of the GridView which you
can use to set a Session variable when the hyperlink is clicked, and then
do a Response.Redire ct to the other page:
I followed this right up to the point where I set the CommandArgument value
during the RowBinding of the GridView. I see the GridView has no RowBinding
event. There is a RowDataBound event. I can modify the handler like this:

protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
e.Row.Cells[0].Text = "What?";
}

I'm not clear on A) how I would access the LinkButton in this cell, B) how I
would respond to the link being clicked, and C) how I would know which row
the link was clicked on in my click handler.

Any chance you could fill this out a bit more for me?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Jan 2 '08 #7
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:%2******** *******@TK2MSFT NGP04.phx.gbl.. .
>>is that "selected row" business restricted to gridviews that have a
select button?

No.

I don't understand how can there be a selected row if a grid has no means
to select one?
http://www.google.co.uk/search?sourc...EventReference
I'm not clear on A) how I would access the LinkButton in this cell,
protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
((LinkButton)e. Row.Cells[0].FindControl("M yLinkButton")). CommandArgument
= "<something >";
}
B) how I would respond to the link being clicked,
By specifying a Command event for the LinkButton in the TemplateColumn, same
way that you would respond to an <asp:Buttonbein g clicked...
and C) how I would know which row the link was clicked on in my click
handler.
You wouldn't need to now, because you've included the data you need in the
LinkButton's CommandArgument property...

http://www.thescripts.com/forum/thread554224.html
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 2 '08 #8
Mark,

I seem to be having trouble with this.
>>>is that "selected row" business restricted to gridviews that have a
select button?

No.

I don't understand how can there be a selected row if a grid has no means
to select one?

http://www.google.co.uk/search?sourc...EventReference
These articles still seem to be talking about making a row selectable.
That's not what I need.
>I'm not clear on A) how I would access the LinkButton in this cell,

protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs
e)
{

((LinkButton)e. Row.Cells[0].FindControl("M yLinkButton")). CommandArgument =
"<something >";
}
>B) how I would respond to the link being clicked,

By specifying a Command event for the LinkButton in the TemplateColumn,
same way that you would respond to an <asp:Buttonbein g clicked...
>and C) how I would know which row the link was clicked on in my click
handler.

You wouldn't need to now, because you've included the data you need in the
LinkButton's CommandArgument property...

http://www.thescripts.com/forum/thread554224.html
Ack, okay, I think I finally wrapped my mind around this. I think I
incorporated some of what you were saying but kind of got the core from some
of the articles.

My GridView column looks like this:

<asp:TemplateFi eld HeaderText="Nam e">
<ItemTemplate >
<asp:LinkButt on ID="lnkName" runat="server" Text='<%# Eval("Name") %>'
CommandName="Vi ewTrainer" CommandArgument ='<%# Eval("UserId") %>'
onclick="lnkNam e_Click">LinkBu tton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateFie ld>

And then I can respond in either of two ways:

protected void lnkName_Click(o bject sender, EventArgs e)
{
Session["ID"] = ((LinkButton)se nder).CommandAr gument;
Response.Redire ct("Trainer.asp x");
}

Or

protected void GridView1_RowCo mmand(object sender, GridViewCommand EventArgs
e)
{
if (e.CommandName == "ViewTraine r")
{
Session["ID"] = (string)e.Comma ndArgument;
Response.Redire ct("Trainer.asp x");
}
}

The first version looks a little cleaner--I may go with that.

Thanks for your help.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jan 3 '08 #9
On Mon, 31 Dec 2007 16:08:24 -0700, "Jonathan Wood"
<jw***@softcirc uits.comwrote:
>Greetings,

My app displays users in a GridView control. I'd like to have the name field
shown in each row of this control a link that displays another page with
information about that user.

But I'm not sure how to approach this. How would I tell the target page
which user to display? I'd prefer not to pass the user's ID on the URL, and
I don't know when I'd get a chance to set a Session variable.

I know I can add a template with a link but, if I set an event handler for
that link, how does it know which row was selected?

Thanks for any tips.
Look at cross-page posting.

regards
A.G.
Jan 3 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1565
by: Jack | last post by:
I have a asp form where among others there are few text boxes and one check box. The checkbox is to indicate whether the entry is final. The checkbox is attahced to a field in table of type yes/no. After saving the documents,the form is refreshed. At this point, if the checkbox has been saved with checked, it shows unchecked, if it has been saved unchecked it shows unchecked. Here, if the checkbox shows checked, I want to disable (or...
5
1937
by: John | last post by:
Hi: I'd like to implement a simple map, which is a 2-D plane with many points, e.g., 100. The points are not evenly distributed, i.e., some points may have two neighbor points; some may have 5 or 6 neighbor points. Could anyone suggest me a data structure for it. Thanks in advance. John
9
4530
by: CW | last post by:
I wrote an HTML based chat application. The front end is built entirely on HTML + javascript. Essentially, I have a hidden frame that's refreshed frequently and any new messages are displayed in another frame using document.write. My problem is that since chat screen can be obscured by other applications/windows, I have no way of informing users that new messages have arrived other than popping the window to the top using window.focus....
5
1754
by: news | last post by:
I have a new situation I'm facing and could use a suggestion or two, as I don't seem to be able to think in the abstract very well. We have a local server which holds all of our image files. We have a remote server that runs our public Web server and mySQL database. I need to be able to run a script that will: Read the contents of a dir on the local server and a. make thumbnails of the files in it b. querey the database and pull...
106
6476
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as dao.recordset
48
3245
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and "huge" Indy is both as a project, in support, development, and use. But Indy is new to the .net world. Indy is a HUGE library implementing over 120 internet protocols and standards and comes with complete source. Its an open source project, but not...
13
2116
by: vincent | last post by:
I made the suggestion "Need built in obfuscation support in C# compiler" to Microsoft. Anyone here agree with me? If yes, please cast your vote on this suggestion to raise its priority.
1
1079
by: msnews.microsoft.com | last post by:
Hi Every one, I need your suggestion. I want to implement a scenario. The Scenario is "I build a web site. I deploy it to web server. Now I want and auto email alter. The responsibility of this alter is that it will send the emails to registered users whether my site is hit by the user or not. It will work independently." For that what you suggest me to implement it in .NET Technology. Can I implement it using .NET Web Services.
11
4498
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.