Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then

Status
Not open for further replies.

asafb

Programmer
Jun 17, 2003
80
US
Hello, I have an ASP page that says if the ID = 13, display more HTML.
Now I want to port it to ASPX.

Here's my code:

<%@ 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 table.
myConnection = New SqlConnection("server=xxxx;" _
& "database=xxxx;user id=xx;pwd=x")
myCommand = New SqlDataAdapter("SELECT * FROM products WHERE IDproduct = " & id, myConnection)

' 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>
<asp:DataList id="mydatalist" runat="server" Width="100%" CellPadding="3" cellspacing="3" RepeatColumns="4">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, ("descriptionLong"))%>
</itemtemplate>
</asp:DataList>
</body>
</html>

^^^
so now i want it to say if id=13, display "hello"
anyway to do this? if i type in the browser " as example.
thanks!
asaf
 
Quick way: if you place either a Literal control or Label on the page, then you can say:

Code:
dim id as String
id = request.querystring("id")

if id = "13" then
   'set the label or literal text
end if
 
'set the label or literal text
Okay, how do you do that?
AB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top