Showing posts with label thisltinput. Show all posts
Showing posts with label thisltinput. Show all posts

Thursday, March 22, 2012

html controls datalist

Yes, 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@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:F55DD0AE-AE5D-46CD-ACDD-FDA2BDC549C7@dotnet.itags.org.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