Hi There,

I am very new to ASP.Net, just started to migrate this week.

I am also sorry if this question has been asked in the Forum already, i have searched but not found anything.

I am looking to pull some data from a database using the following code:


dim objCmd2 as OleDbCommand = new OleDbCommand("spSubPage", conn)
objCmd2.CommandType = CommandType.StoredProcedure
dim ObjReader2 as OleDbDataReader

objParam = objCmd2.Parameters.Add("@PageID", OleDbType.BSTR)
objParam.Direction = ParameterDirection.Input
objParam.Value = PageID

try
objCmd2.Connection.Open()
objReader2 = objCmd2.ExecuteReader()

dgSubPage.DataSource = objReader2
dgSubPage.DataBind()

objCmd2.Connection.Close()
catch ex as OleDbException
lblMessage.Text = "Sorry, there was an error"
end try

i am using a DataGrid to display the data.

This code is for a Content Management App where this query pulls out the sub page data and displayes the sub links on the right. Now, if there are no sublinks i dont want the sub link box to be displayed but i can't think of a way to do it in .Net, so i need some help. In asp this would be very simple, just using:


if not rsQuery.EOF
-- DISPLAY TABLE TOP --
while not rsQuery.EOF
-- DISPLAY SUB LINKS --
rsQuery.MoveNext
wend
--DISPLAY TABLE BASE
end if

but obviously this is not as efficient.

Look forward to hearing your suggestions, this (i think it will end up to be simple) task has been fustrating me for 2days now!

DiNo

This article has been dead for over six months. Start a new discussion instead.