473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Gridview data column links to search of other page?

I have a gridview on another page with a column that will link to this
page. I'm flirting with design options, but am considering a template
field with hyperlink navigateurl that includes a query string ?
search=mydata container.

My question/challenge, is that I want to use that query string to set
a textbox on the called page, but then need the query string to no
longer be visible in the url espectially after a refersh or other
selection. I guess I could use response.redirect to clear the query
string, but won't that cause my textbox viewstate to be cleared
defeating the whole exercise.

None of this would be a problem, If I could somehow link a gridview
column to a subroutine where I set a session variable and call the
destination search page. A session variable would be easy to remove
after using it. In this scinereo, how can I like data in a gridview to
a row command or codebehind subrutine on the same page?

Thanks for any help or information!

Apr 2 '07 #1
3 3855
Along these lines:

Is there any way to link text to a subroutine?

A hyperlink, links to a url, that I know of , there is no way to link
a hyperlink to a subroutine right?

A linkbutton, is a button that does call a subroutine, but it's a
button.

Any way to link text (not a button) to a subroutine?

I'm trying to do this from bound data in a gridview. I need the
gridview to show the data as a link, and when the link is selected a
subroutine is executed.

possible? how?

Thanks for any help or information!

Apr 2 '07 #2
On Apr 2, 4:31 pm, "jobs" <j...@webdos.comwrote:
I have a gridview on another page with a column that will link to this
page. I'm flirting with design options, but am considering a template
field with hyperlink navigateurl that includes a query string ?
search=mydata container.

My question/challenge, is that I want to use that query string to set
a textbox on the called page, but then need the query string to no
longer be visible in the url espectially after a refersh or other
selection. I guess I could use response.redirect to clear the query
string, but won't that cause my textbox viewstate to be cleared
defeating the whole exercise.

None of this would be a problem, If I could somehow link a gridview
column to a subroutine where I set a session variable and call the
destination search page. A session variable would be easy to remove
after using it. In this scinereo, how can I like data in a gridview to
a row command or codebehind subrutine on the same page?

Thanks for any help or information!

You can try using the SelectedIndexChanged event. In the example
below when the LinkButton is clicked the event will be fired and do a
Server.Transfer to another page. This second page can get the
selected record's unique id. This way you won't pass anything in the
url.
-------
Page1

private int _selectedUID;

public int SelectedUID
{
get { return _selectedUID; }
set { _selectedUID = value; }
}

protected void gvSearchResults_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedUID = (int)gvSearchResults.SelectedValue;
Server.Transfer("Page2.aspx", true);
}

-------
<asp:GridView ID="gvSearchResults" runat="server"
AutoGenerateColumns="false" AutoGenerateSelectButton="false"
GridLines="none" DataKeyNames="uid" SelectedIndex="0"
OnRowDataBound="gvSearchResults_OnRowDataBound"
OnSelectedIndexChanged="gvSearchResults_SelectedIn dexChanged" Font-
Size="x-Small" CellSpacing="1">
<Columns>

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDetail" runat="server"
CommandName="Select" Text="View Detail" ForeColor="darkBlue" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

--------------------
Page2

int UID = this.PreviousPage.SelectedUID;

-----
<%@ PreviousPageType VirtualPath="~/Page1.aspx" %>

Apr 2 '07 #3
On Apr 3, 12:21 am, "Robert Fernandez" <robert.fernan...@gmail.com>
wrote:
On Apr 2, 4:31 pm, "jobs" <j...@webdos.comwrote:


I have a gridview on another page with a column that will link to this
page. I'm flirting with design options, but am considering a template
field with hyperlink navigateurl that includes a query string ?
search=mydata container.
My question/challenge, is that I want to use that query string to set
a textbox on the called page, but then need the query string to no
longer be visible in the url espectially after a refersh or other
selection. I guess I could use response.redirect to clear the query
string, but won't that cause my textbox viewstate to be cleared
defeating the whole exercise.
None of this would be a problem, If I could somehow link a gridview
column to a subroutine where I set a session variable and call the
destination search page. A session variable would be easy to remove
after using it. In this scinereo, how can I like data in a gridview to
a row command or codebehind subrutine on the same page?
Thanks for any help or information!

You can try using the SelectedIndexChanged event. In the example
below when the LinkButton is clicked the event will be fired and do a
Server.Transfer to another page. This second page can get the
selected record's unique id. This way you won't pass anything in the
url.
-------
Page1

private int _selectedUID;

public int SelectedUID
{
get { return _selectedUID; }
set { _selectedUID = value; }
}

protected void gvSearchResults_SelectedIndexChanged(object sender,
EventArgs e)
{
SelectedUID = (int)gvSearchResults.SelectedValue;
Server.Transfer("Page2.aspx", true);
}

-------
<asp:GridView ID="gvSearchResults" runat="server"
AutoGenerateColumns="false" AutoGenerateSelectButton="false"
GridLines="none" DataKeyNames="uid" SelectedIndex="0"
OnRowDataBound="gvSearchResults_OnRowDataBound"
OnSelectedIndexChanged="gvSearchResults_SelectedIn dexChanged" Font-
Size="x-Small" CellSpacing="1">
<Columns>

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDetail" runat="server"
CommandName="Select" Text="View Detail" ForeColor="darkBlue" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

--------------------
Page2

int UID = this.PreviousPage.SelectedUID;

-----
<%@ PreviousPageType VirtualPath="~/Page1.aspx" %>- Hide quoted text -

- Show quoted text -
http://groups.google.com/group/micro...bb2adf1db7bab4

Apr 2 '07 #4

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

Similar topics

3
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
13
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The...
0
by: russganz | last post by:
I have a gridview that displays user ratings as 'stars' from a jpg file. The template field is defined as <asp:TemplateField HeaderText="User Rating"> <ItemTemplate> <img src='<%#...
2
by: Bishop | last post by:
The default gridview paging links are JavaScript and it looks like there is no way for search engines to follow them. Any ideas on what I can do to allow search engines to follow the links so they...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
4
by: Jeff | last post by:
Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET GridView with paging and sorting. One of the columns of this Gridview is a template column (LinkButton). The data being...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.