.net - how to pass sql table name using session on other page in asp.net -


I have the name of pages glass.aspx, shirt.aspx. These pages contain images when someone clicks on any image, then they redirect to the product.aspx page. Product.aspx contains all the details of the image.

My product.aspx code

  & asp: SqlDataSource id = "SqlDataSource1" runat = "server" ConnectionString = "[password] =" provider name = "system. Where [[ID] = @ id] from "DataSQLClient" Select "Commander =" Selection [ID], [ImagePath], [ImageNenam], [Description], [Value] [Best] & Lt; SelectParameters & gt; & Lt; Asp: QueryStringParameter name = "id" QueryStringField = "id" type = "decimal" /> & lt; / SelectParameters & gt; & Lt; / ASP: SQLDataSource & gt; & Lt; ASP: Data List ID = "Data List 1" Runat = "Server" DatacoursID = "SQLDitasource 1" & gt; & Lt; ItemTemplate & gt; & Lt; Asp: Image ID = "Image1" runat = "server" width = "200px" height = "300" ImageUrl = '& lt;% # Eval ("ImagePath", "~ / admin / {0}")% & gt; ; '/ & Gt; & Lt; Br / & gt; & Lt; Asp: Label ID = "ImageUrlLabel" font-size = "XX-Large" runat = "server" ForeColor = "Red" Text = '& lt;% # Eval ("ImageName")% & gt; Visible = "false" & gt; & Lt; / Asp: Label & gt; & Lt; Br / & gt; & Lt; Asp: Label ID = "DescriptionLabel" font-size = "XX-Large" runat = "server" ForeColor = "Red" Text = '& lt;% # Eval ("Details")% & gt; & Gt; & Lt; / ASP: Labels & gt; & Lt; Br / & gt; -% & gt;  

I want to pass the session on the code below when clicking any image on any image

  Selectcommand = "SELECT [id], [ImagePath ], [([Id] = @id]  

It seems that you choose Trying to pass the name of the table?

I believe that the fastest way to do this work is to give your table name in the query string and on back end on your product page Dynamically selectCommand your .

glass.aspx

   & lt; a href = Product.aspx? Producttype = bestsherwani & Gt; ASP: Image ID = "Image 1" run = "server" width = "200px" height = "300" image URL = '& lt;% # Eval ("ImagePath", "~ / admin / {0} ") Save the case of empty query string SqlDataSource1.SelectCommand = @" SELECT [id], [ImagePath] "(%); & gt; Protected Zero Page_load  (object sender, eventArgse E) {// Toddo; ], [ImageName], [description], [value] FROM "+ Request.QueryString [" product type "] +" WHERE ([id] = @id] ";}  

You should do whatever you want Yes, though your big problem is that you have data set up and it is probable for failure and unnecessary complexity.

It seems that there is a separate table for each of your products and this is not a good design. Instead you should have a table and a ProductType field [id with foreign key to isolate the ID type]. You can then type your outer section on your product page. As you have now, a wrongly passed table name will remove a big ugly SQL error.

You should also look at the three-level design and use your SQL and Object data source in stored procedures.

Cheers


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -