Gridview data column links to search of other page?

J

jobs

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!
 
J

jobs

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!
 
R

Robert Fernandez

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_SelectedIndexChanged" 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>
 
A

Alexey Smirnov

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_SelectedIndexChanged" 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>

http://groups.google.com/group/micr...read/thread/b6b009ff2976bd76/d5bb2adf1db7bab4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top