Thursday, 15 May 2014

c# - How can I pass values of a listview from aspx page to another ? -


I am working on class projects where I am creating a list view in a .view page. I can display the database through this list view but I can not move the value of the selected item from another .aspx page to another.

My design code is like the following:

  & lt; Asp: listView id = "lvPresent" runat = "server" DataSourceID = "SqlDataSource1" OnItemDataBound = "lvPresent_ItemDataBound" & gt; & Lt; LayoutTemplate & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; ASP: Place Holder ID = "Item Place Holder" Runat = "Server" & gt; & Lt; / Asp: place holder & gt; & Lt; / LayoutTemplate & gt; & Lt; ItemTemplate & gt; & Lt; TD & gt; & Lt; ASP: Hyperlink ID = "HyperLink 1" Runat = "Server" & gt; & Lt; Asp: Image ID = "ImageButton1" runat = "Server" ImageUrl = '& lt;% # Eval ("url")%> Height = "200px" width = "250px" /> & Lt; / ASP: Hyperlink & gt; & Lt; / TD & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: ListView & gt;  

What should I do to make this work?

You can use the querystring to send the URL to another page Are there. Modify your hyperlink and navigate

  navigateUrl = '& lt;% #' add yourNextPageName.aspx? ImgURL = "+ Eval ("Url")%> ' 

Just replace the code to you: -

  & asp: hyperlink id = "hyperlink 1" runat = "server" & gt; & Lt; Asp: Image ID = "ImageButton1" runat = "Server" ImageUrl = '& lt;% # Eval ("url")%> Height = "200px" width = "250px" /> & Lt; / ASP: Hyperlink & gt;  

  and asp: hyperlink id = "hyperlink 1" runat = "server" navigate URL = '& lt;% #' yourNextPageName.aspx? ImgURL = "+ + Eval (" url ")%>> & gt; & lt; asp: image id =" ImageButton1 "runat =" server "ImageUrl = '& lt;% # Eval (" url ")% & Gt; ' Height = "200px" width = "250px" /> & lt; / ASP: hyperlink & gt;  

On that page, you can access image url like this:

string imgurl = Request.QueryString ["imgURL"];

Contain image control on that page, specify this image on page load, if If your image control ID image is 1 then you can assign it to the page load of the page like: -

image 1.IJURL = IMGeral


No comments:

Post a Comment