 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 30th, 2006, 08:25 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
datalist not displaying.. help me please
i have 2 pages
page1.aspx
--> i have a datalist with an image control and a hyperlink.
i m trying to display
item picture-->in image control
ID ---> in hyperlink
my aim is that
ID-->onclick-->navigate to page2.aspx(page2.aspx contains details of the item)
when the ID get passed to page2.aspx, i want to display the details of that particular item
i have set the datsource and datamember in the datalist properties and have the follwng code.
HTML
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datalist id="DataList1" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 128px"
runat="server" RepeatDirection="Horizontal" CellSpacing="3" CellPadding="3" RepeatColumns="3"
Width="488px" BorderColor="White" BorderStyle="Ridge" BackColor="White" BorderWidth="1px"
Height="247px" DataSource="<%# DataSet11 %>" DataMember="Items">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
<HeaderTemplate>
CHOOSE YOUR PRODUCT
</HeaderTemplate>
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<SeparatorStyle BorderColor="#400040"></SeparatorStyle>
<ItemStyle HorizontalAlign="Center" Height="2px" ForeColor="Black" BorderColor="#400040" Width="200px"
BackColor="#DEDFDE"></ItemStyle>
<ItemTemplate>
<P>
<asp:Image id=Image1 runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem,"Image")%>'>
</asp:Image>
<P>
<asp:HyperLink id=HyperLink1 Runat="server" text= '<%# DataBinder.Eval(Container.DataItem,"[ID]".tostring()) %>' NavigateUrl='<%# "page2.aspx?id=" & server.UrlEncode(Container.DataItem("[ID]"))%>'/>
</asp:HyperLink></P>
<P> </P>
</ItemTemplate>
<HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BorderColor="Maroon" BackColor="#4A3C8C"></HeaderStyle>
</asp:datalist></form>
</body>
IN PAGE-LOAD
Dim da As New SqlDataAdapter("select [ ID],Image from Items", con)
Dim dataset11 As New DataSet
da.Fill(dataset11, "Items")
DataList1.DataSource = dataset11.Tables(0)
DataList1.DataBind()
" BUT I AM GETTING THE HEADER ONLY"
can anyone help me in this context please
thanks
|
|

August 30th, 2006, 08:34 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Why are you defining your datasource and datamember inside the control itself? This should be handled automatically when you call .DataSource and .DataBind() in your code.
Does your SQL query actually return a resultset?
"The one language all programmers understand is profanity."
|
|

August 30th, 2006, 09:06 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
now i have set the datasource in code behind only, not in the datalist properties
but still i am getting the header only.
select [ ID],Image from Items
i am getting the result set for this query.
but
SELECT *
FROM dbo.Items WHERE ([ID] = 11469)
this is the select stmt in the page2.aspx, where i am trying to display the informations based on the ID, which i am passing frm page1.aspx
ON EXECUTING THIS I AM GETTING AN EROR
"SYNTAX ERROR IN CONVERTING nvarchar value 146-7-8 to colum of data ype int"
ACTUALLY I HAVE A RECORD WITH ID 146-7-8
ALL THE OTHER RECORDS HAVE THEIR ID IN NUMBERS ONLY.
I AM CONFUSED, I THINK THERE IS SOME PROBLEM IN TABLE STRUCTURE?
WAT IS UR SUGGESTION?
|
|

August 30th, 2006, 09:45 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Somewhere along the way you are trying to cast that value to INT which is, obviously, not allowed. You have to figure out if this error is occuring in SQL or somewhere on your asp page.
"The one language all programmers understand is profanity."
|
|

August 30th, 2006, 02:10 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i got the images with their id in hyperlink
now on clicking the hyperlink below the image, i got that value, passed to page2.aspx
page2.aspx is displayed.
but the detailed inf is not there
in the address, i can get the ID get passed
in page2.aspx i have 3 labels and an image control
in labels, i want to display ID,Unitprice, and Descritpion based on ID
inimage control, i want to display the image of that ID(all are in the table)
WHY IS THEN THE INFORMATIONS NOT DISPLAYED, EVEN IF THE ID GET PASSED??
CAN U PLEASE HELP ME
PAGE2.ASPX(CODE BEHIND)
Dim da As New SqlDataAdapter("select * from Items where [ID]= ' " & Request("id") & "'", con)
Dim Dataset21 As New DataSet
da.Fill(Dataset21, "Items")
Dim dc As DataColumn
Dim dr As DataRow
For Each dr In Dataset21.Tables(0).Rows
lblDesc.Text = dr.Item("Description")
lblID.Text = dr.Item("[ID]")
lblUnitprice.Text = dr.Item("UnitPrice")
Next
can u please say why is this?
thanks
|
|

August 30th, 2006, 06:13 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
if you are sure that your query is returning data to you, then I do not know why. What I do know is that your for loop is unnecessary;
You are only concerned with 3 columns from one row, so the for only exectues one time anyway so:
lblDesc.Text = dataset21.Tables(0).Rows(0).item("description")
etc etc
Outside of that, void of any errors or such, you should have data in your dataset.
"The one language all programmers understand is profanity."
|
|

August 31st, 2006, 02:17 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
Just looking at the inormation you sent there seems to be a conflict in using the reserved word "ID", as in ID=form name on the form tag. The contents of the ID would be the form name that causes the error in that IIS is trying to convert the nvarchar field to an integer. As another member suggested, check your table structure and rename tha field and verify that the primary key you are passing is the same data type as the primary key in the receiving table (Items).
Hope this helps.
|
|

August 31st, 2006, 06:32 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The keyword ID is reserved in TSQL, however when you enclose it in braces [] it is ignored as a reserved word and it should not cause a conflict.
As far as the HTML goes, if the query string is ./file.aspx?id=nn doing a Request will pull the value of id from the query string.
"The one language all programmers understand is profanity."
|
|

August 31st, 2006, 06:44 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Wait, this might be your problem. When referencing your column, ID, in SQL you have to reference it with braces so [ID], however, when it is actually pulled from the database the column name will be just ID without the braces.
Try referencing the ID column without the braces.
hth.
"The one language all programmers understand is profanity."
|
|

August 31st, 2006, 07:41 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
lblDesc.Text = Dataset21.Tables(0).Rows(0).Item("Description")
IT SAYS "THERE IS NO ROW AT POSITION 0"
but i do have 6 records in my dataset
why is this?
can u plese tel
|
|
 |