Thursday, March 22, 2012
html controls datalist
In a datalist place an HTML hidden control like such..
<input type="hidden" id="hiddenctl"
value='<%#Databinder.Eval(Container.DataItem, "dbfield")%>'>
Then on the DataListItemCommand retrieve the value of that control using the
findcontrol method or something similar?
ObjectType myhiddenfield = (ObjectType)e.Item.FindControl("hiddenctl");
string thevalue = myhiddenfield.Text;
This simple task has turned into a nightmare simply because I need to pass
several variables from a datalist command to the method using Postback.
Thanks
e.Item.FindYes, it is possible. It goes like this:
<input type=hidden id="hiddenctl" value='<%# ... %>' runat=server>
In the server-side event handler for ItemCommand:
HtmlInputHidden c = (HtmlInputHidden) e.Item.FindControl ("hiddenctl");
string thevalue = c.Value;
Hope this helps.
"Marty U." <MartyU@.discussions.microsoft.com> wrote in message
news:F55DD0AE-AE5D-46CD-ACDD-FDA2BDC549C7@.microsoft.com...
Is it possible to do the following:
In a datalist place an HTML hidden control like such..
<input type="hidden" id="hiddenctl"
value='<%#Databinder.Eval(Container.DataItem, "dbfield")%>'>
Then on the DataListItemCommand retrieve the value of that control using the
findcontrol method or something similar?
ObjectType myhiddenfield = (ObjectType)e.Item.FindControl("hiddenctl");
string thevalue = myhiddenfield.Text;
This simple task has turned into a nightmare simply because I need to pass
several variables from a datalist command to the method using Postback.
Thanks
e.Item.Find
HTML control value to an ASP.NET value
<INPUT ID="hdnFPrintNA" runat=server STYLE="Z-INDEX: 163; LEFT: 165px; WIDTH: 38px; POSITION: absolute; TOP: 5px; HEIGHT: 22px" TYPE="hidden" SIZE="1">
--------------
When the user presses my Server control button to clear the screen, I would like to clear the hidden text field as well. The below doesn't work.
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
hdnFPrintNA.Text = ""
End Sub
-------------
I have been searching this site to try and find the answer but I am only getting confused. Can any one point me in the right direction and tell me how to solve this problem?
ThanksI think it should read
hdnFPrintNA.value =""
Try using "hdnFPrintNA.Value" instead. And also remember to define your Html Control as:
'System.Web.UI.HtmlControls.HtmlInputHidden'
Thank you both for your help. It works now. :)