Hello, how do you create an aspx page with a query string i.e. test.aspx?id=5,
where basically the datalist would retrieve the data just for that record. i did it in asp, but i need help to do it in .net. thanks guys!
<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
' Create a connection to the "pubs" SQL database located
' on the local computer.
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
Dim id
id=request.querystring("id")
' Connect to the SQL database using a SQL SELECT query to get
' all the data from the "data" table.
myConnection = New SqlConnection("server=XXXX;" _
& "database=XXXX;user id=sa;pwd=XXXX")
myCommand = New SqlDataAdapter("SELECT * FROM data WHERE id = " @id ,myConnection)
^^^ this doesn't work!!!! is it @id, or & id?
' Create and fill a DataSet.
Dim ds As Dataset = new DataSet()
myCommand.Fill(ds)
' Bind MyRepeater to the DataSet. MyRepeater is the ID of the
' Repeater control in the HTML section of the page.
mydatalist.DataSource = ds
Mydatalist.DataBind()
End SUb
</script>
<html>
<head>
</head>
<body>
<aspataList id="mydatalist" runat="server" Width="100%" CellPadding="3" cellspacing="3" RepeatColumns="4">
<itemtemplate>
<p align="center">
<a href="estore/scripts/prodview.asp?idproduct=<%# DataBinder.Eval(Container.DataItem, ("idProduct"))%>">
<asp:Image id="Image1" runat="server" src='<%# DataBinder.Eval(Container.DataItem, ("smallimageurl"))%>'></asp:Image>
<br />
<font face="Verdana" style="font-size: 9pt; font-weight: 700"> <%# DataBinder.Eval(Container.DataItem, ("description"))%> </font></a></font></a><font face="Verdana" style="font-size: 9pt; font-weight: 700">
<br />
$<%# DataBinder.Eval(Container.DataItem, ("price"))%>
<br />
<font face="Verdana" style="font-size: 9pt; font-weight: 300"><%# DataBinder.Eval(Container.DataItem, ("descriptionLong"))%>
</itemtemplate>
</aspataList>
</body>
</html>
where basically the datalist would retrieve the data just for that record. i did it in asp, but i need help to do it in .net. thanks guys!
<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
' Create a connection to the "pubs" SQL database located
' on the local computer.
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
Dim id
id=request.querystring("id")
' Connect to the SQL database using a SQL SELECT query to get
' all the data from the "data" table.
myConnection = New SqlConnection("server=XXXX;" _
& "database=XXXX;user id=sa;pwd=XXXX")
myCommand = New SqlDataAdapter("SELECT * FROM data WHERE id = " @id ,myConnection)
^^^ this doesn't work!!!! is it @id, or & id?
' Create and fill a DataSet.
Dim ds As Dataset = new DataSet()
myCommand.Fill(ds)
' Bind MyRepeater to the DataSet. MyRepeater is the ID of the
' Repeater control in the HTML section of the page.
mydatalist.DataSource = ds
Mydatalist.DataBind()
End SUb
</script>
<html>
<head>
</head>
<body>
<aspataList id="mydatalist" runat="server" Width="100%" CellPadding="3" cellspacing="3" RepeatColumns="4">
<itemtemplate>
<p align="center">
<a href="estore/scripts/prodview.asp?idproduct=<%# DataBinder.Eval(Container.DataItem, ("idProduct"))%>">
<asp:Image id="Image1" runat="server" src='<%# DataBinder.Eval(Container.DataItem, ("smallimageurl"))%>'></asp:Image>
<br />
<font face="Verdana" style="font-size: 9pt; font-weight: 700"> <%# DataBinder.Eval(Container.DataItem, ("description"))%> </font></a></font></a><font face="Verdana" style="font-size: 9pt; font-weight: 700">
<br />
$<%# DataBinder.Eval(Container.DataItem, ("price"))%>
<br />
<font face="Verdana" style="font-size: 9pt; font-weight: 300"><%# DataBinder.Eval(Container.DataItem, ("descriptionLong"))%>
</itemtemplate>
</aspataList>
</body>
</html>