I am new to ASP.NET in general, but I do have experience with classic
ASP. I am using a DataList control with a hidden value to submit to a
different page, however I do not know how to get to that hidden value.
Here is my DataList control code:
<asp:DataList ID="DataList1" runat="server"
DataSourceID="S qlDataSource1" RepeatColumns=" 4">
<ItemTemplate >
<%#DataBinder.E val(Container.D ataItem, "itemname") %> <br>
$<%#FormatNumbe r(DataBinder.Ev al(Container.Da taItem, "itemprice" ),
2)%> <br>
<%#DataBinder.E val(Container.D ataItem, "itemdescriptio n")%> <br>
<%#Format(DataB inder.Eval(Cont ainer.DataItem, "itemaddtim e"), "ddd
MMMM d, yyyy h:mm tt")%> <br>
<asp:ImageButto n ID="ImageButton 1" runat="server" ImageUrl='<%#
"images/" & Eval("picfilena me") %>' PostBackUrl='<% # "cart.aspx? id=" &
eval("itemid") %>' Width="200px" BorderStyle="No ne" /><br>
<asp:Button id="submit" runat="server" Text="Order" PostBackUrl='<% #
"cart.aspx? id=" & eval("itemid") %>' />
<asp:HiddenFiel d runat="server" Value='<%# eval("itemid") %>'
ID="itemid" />
</ItemTemplate>
</asp:DataList>
What code to I need on cart.aspx to get the hidden value? 3 3116
a control in a datalist does not exist like a normal control on your page.
It needs to be casted as such
I too found this a hard concept to understand when changing from classic ASP
to .NET
NOw is this value your trying to get, record specific?
i.e. are you using one of the DataLists's inbuilt commands like the
OnItemCommand, or the OnEditCommand.
if so, you can get the value like follows:
((HiddenField)e .Item.FindContr ol("itemid")).V alue; --> c#
ctype(e.Item.Fi ndControl("item id"), HiddenField).Va lue --> vb (something
like that, i'm not a vb coder)
If you are not trying to get this from a given item, but a more general
value for the whole datalist,
you can look at storing this hidden outside of the DataList, then you can
get it with:
itemid.Value
But as long as its in the datalist , you'll have to cast a specific items
hiddenfield
HTH
<we***********@ ebtech.net> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com... I am new to ASP.NET in general, but I do have experience with classic ASP. I am using a DataList control with a hidden value to submit to a different page, however I do not know how to get to that hidden value. Here is my DataList control code:
<asp:DataList ID="DataList1" runat="server" DataSourceID="S qlDataSource1" RepeatColumns=" 4"> <ItemTemplate > <%#DataBinder.E val(Container.D ataItem, "itemname") %> <br> $<%#FormatNumbe r(DataBinder.Ev al(Container.Da taItem, "itemprice" ), 2)%> <br> <%#DataBinder.E val(Container.D ataItem, "itemdescriptio n")%> <br> <%#Format(DataB inder.Eval(Cont ainer.DataItem, "itemaddtim e"), "ddd MMMM d, yyyy h:mm tt")%> <br> <asp:ImageButto n ID="ImageButton 1" runat="server" ImageUrl='<%# "images/" & Eval("picfilena me") %>' PostBackUrl='<% # "cart.aspx? id=" & eval("itemid") %>' Width="200px" BorderStyle="No ne" /><br> <asp:Button id="submit" runat="server" Text="Order" PostBackUrl='<% # "cart.aspx? id=" & eval("itemid") %>' /> <asp:HiddenFiel d runat="server" Value='<%# eval("itemid") %>' ID="itemid" /> </ItemTemplate> </asp:DataList>
What code to I need on cart.aspx to get the hidden value?
I think the code below is on the right track but I am not too sure:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
dim i as HiddenField
i =ctype(previous page.FindContro l("itemid"),Hid denField)
response.Write (i)
End Sub
So your trying to push it into a new page, like a form post.
I'm not sure if that'll work, but worth a try.
You must try utilise the Postback feature in .NET, i find this far superior
than the ASP traditional form post.
Also, explore the in-build data commands in the datalist.
instead of EventArgs, you'll have DataListCommand EventArgs and that'll give
you access to controls within your datalist.
but if your code is working, its working
<we***********@ ebtech.net> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. . I think the code below is on the right track but I am not too sure:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load dim i as HiddenField i =ctype(previous page.FindContro l("itemid"),Hid denField) response.Write (i) End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bruce W..1 |
last post by:
What's the best way to keep a hidden value? It doesn't need encryption or any protection.
I realize that I could use a Label control's viewstate, and just make it not visible, but
that doesn't seem efficient. Or I could use a session variable, or a cookie...
To simply hide a simple value in a page, what's the best way to do this?
...
|
by: duancg |
last post by:
Hi,
I wonder if someone could help since I wasn't able to find the answer
through search. I have a simple .aspx page that shows data from a
database table, as a table in UI. Now the data uses 1~12 to represent
months, but I want to show them as Jan/.../Dec. So I thought I could
write a simple function to convert it and call that function...
|
by: Bindia |
last post by:
Hi,
I would like to know how to access hidden value posted from another html page.
For example.
*I have 2 pages Page A and Page B. I have a hidden value 'hide' in page A.
*When i click on a button/link i move to page B.
*How do i access the hidden value 'hide' (of page A) in page B using javascript.
|
by: rag84dec |
last post by:
Hi,
I have a vector in one file which has many items stored and i want to save the value from that file to other.both are using completely different classes, can anyone help?
Do I need to use EXTERN?
|
by: Fary4u |
last post by:
Hi Guys
i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem
hidden file value, multiple form or popup uploading.
1-
<SCRIPT TYPE="text/javascript">
function popupform(myform, windowname)
| |
by: scout3014 |
last post by:
Hi all
I need help on one matter here. I have a php file which takes values
from the form which calls the page and displays it for confirmation. I
try to display using this:
From: <input name="start" type="hidden" value="<?php echo $startDate; ?
|
by: JCCDevel |
last post by:
Hi All,
I'm not too proficient in Javascript but am trying to help a friend
out. Bascially, the page we are having trouble with is loaded with a
numerical value in the url string. Example:
http://www.webpage.com/v4/payment_pg.php?FeeCalcTotalDecimal%20=49.50
I then parse the string to get the total. I then want to assign the
value to...
|
by: FrankF |
last post by:
Two years ago, member acoder gave patient help to a newbie whose function worked in IE but not in Firefox. I have a similar problem, but mine works fine in Firefox and exhibits astonishing behavior in IE.
function chooseList(x)
{
alert(document.getElementById('myHiddenField').value);
document.getElementById('myHiddenField').value=x;...
|
by: nicnac |
last post by:
Hi,
I'm self learning javascript - so any pointers are welcomed!!
I have an issue passing a form and array from one function to another.
I tried many variations !
I can't get this to work and I can't get this issue out of my head !!!!
So I'm obviously missing something really simple and can't see it or it can't be done with my limited...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |