I have set up a gridview table that filters information from an SQL database, I have added a select option for each row in the table. I have it so that when the user hits select for that row, they are sent to the next webpage (which is another webform).
I need this webpage that the user is sent to, to display information about the item that the user selected.
Page1 - User selects item > Page2 - Specific fields of the selected Page1-item are displayed and editable
How can I do this? I am new to all of this so please be as descriptive as possible.
Please let me know if this needs further clarification
now on the second page.. use the server.querystring["id"] to get the value of the ID
and based upon that id retreive the data and display it
nsa08001
I have set up a gridview table that filters information from an SQL database, I have added a select option for each row in the table. I have it so that when the user hits select for that row, they are sent to the next webpage (which is another webform).
I need this webpage that the user is sent to, to display information about the item that the user selected.
Page1 - User selects item > Page2 - Specific fields of the selected Page1-item are displayed and editable
How can I do this?
Please let me know if this needs further clarification
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (!ispostback) Then
string id = server.request.querystring["id"].tostring();
End If
End Sub
<(!postback)> Error: "Leading '.' or '!' can only appear inside a 'With' statement."
<string> Error: "'String' is a class type and cannot be used as an expression."
<id> Error: "'.' expected"
<server.request> Error: "'request' is not a member of 'System.Web.HttpServerUtility'."
Sorry, but as I said, I am very new to this, and have spent 9 hours on this page/problem already.
man you should have me earlier..that you are using vb.net :P
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
if not ispostback then
dim id as string = server.request.querystring["id"].tostring
end if
End Sub
nsa08001
0 Points
37 Posts
Need to pass single gridview value to another page
Apr 12, 2012 12:56 AM|LINK
I have set up a gridview table that filters information from an SQL database, I have added a select option for each row in the table. I have it so that when the user hits select for that row, they are sent to the next webpage (which is another webform). I need this webpage that the user is sent to, to display information about the item that the user selected.
Page1 - User selects item > Page2 - Specific fields of the selected Page1-item are displayed and editable
How can I do this? I am new to all of this so please be as descriptive as possible.
Please let me know if this needs further clarification
Using MS Visual Web Developer 2010 Express
Evolutionz
Member
261 Points
95 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 01:48 AM|LINK
you can use the link button instead of the Select
you need to create a template field and bind the unique id to it
<ItemTemplate> <asp:LinkButton ID="LinkButton" runat="server" PostBackUrl='<%# "~/yourpage.aspx?id="+ Bind("ID") %>' Text="Select"></asp:LinkButton> </ItemTemplate>now on the second page.. use the server.querystring["id"] to get the value of the ID
and based upon that id retreive the data and display it
nsa08001
0 Points
37 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 01:54 AM|LINK
Thank you for the reply, I am getting the error that ItemTemplate is not supported.
Evolutionz
Member
261 Points
95 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 01:58 AM|LINK
yes...i thought you know about the asp:templatefields.
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:LinkButton ID="LinkButton" runat="server"
PostBackUrl='<%# "~/yourpage.aspx?id="+ Bind("ID") %>' Text="Select"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
nsa08001
0 Points
37 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 02:02 AM|LINK
Thank you again for the quick responses. But I'm not sure what to put under Page_Load of the second page, to display information.
Evolutionz
Member
261 Points
95 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 02:24 AM|LINK
can you tell me how are you retreiving the data on the gridview...
nsa08001
0 Points
37 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 02:27 AM|LINK
Either textbox or another gridview
Evolutionz
Member
261 Points
95 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 02:38 AM|LINK
well on the page load for the second page use this
if(!ispostback)
{
string id=server.request.querystring["id"].tostring();
// now using this id retreive the data from the database and display it in textboxes..
}
nsa08001
0 Points
37 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 03:01 AM|LINK
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If (!ispostback) Then string id = server.request.querystring["id"].tostring(); End If End Sub<string> Error: "'String' is a class type and cannot be used as an expression."
<id> Error: "'.' expected"
<server.request> Error: "'request' is not a member of 'System.Web.HttpServerUtility'."
Sorry, but as I said, I am very new to this, and have spent 9 hours on this page/problem already.
Evolutionz
Member
261 Points
95 Posts
Re: Need to pass single gridview value to another page
Apr 12, 2012 03:36 AM|LINK
man you should have me earlier..that you are using vb.net :P
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load if not ispostback then dim id as string = server.request.querystring["id"].tostring end if End Sub