Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

How to display data of datagridview to another web page on selected row of data, without using Query string?


I don't want to use query string, i don't display data in query string.
I am using Select Command field.

Please help me.
How it can be possible?

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted

The simplest could could be to keep the data of the gridviewrow in a session or an application object and access it on the next page.

Or if you transfer execution from the source page to the target page by using the Transfer method, the target page can access public properties in the source page.

ASPX Page(SourcePage.aspx):

ASP.NET
<asp:TextBox ID="txtData" runat="server"></asp:TextBox>
<asp:Button ID="btnPublicProperties" runat="server" Text="Public Properties" OnClick="btnPublicProperties_Click" />


Code-Behind:

C#
 protected void btnPublicProperties_Click(object sender, EventArgs e)
{
    Server.Transfer("Target.aspx");
}
 public string PublicData
{
    get
    {
        return txtData.Text;
    }
}


Receiver ASPX Page:

On the target Web Forms page, add a @ PreviousPageType page directive that points to the source page.

HTML
<%@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>


C#
Label1.Text = PreviousPage.PublicData;
 
Share this answer
 
v3
I guess yesterday also you raise the same question we already provide some solution for this. Anyhow I will share you how to implement this;

Remember one thing Query strings never helps you to call complex type data, and their is a size limitation also. Instead of that you can use Sessions and store the selected records into Session object and based on session data in page2 you can show your data as you want.

Hope this will helpful to you..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900