input type=hidden

S

simon

I have input html control in my dataGrid.
When user click some button I would like to get it's value from codeBehind.

<ItemTemplate>
.......
<input type=hidden runat=server id="txtExists" value='<%#
Container.DataItem( "exists" ) %>'>
</ItemTemplate>

Public txtExists As System.Web.UI.HtmlControls.HtmlInputHidden

Private Sub dgdAdvert_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgdAdvert.ItemCommand

dim exists as string

exists=txtExists.value

.......

I alays get nothing. Where is the problem?

Thank you,
Simon
 
G

Guest

Try to use a <asp:TextBox id=txtExists runat=server visible=False value='...'> item instead of a <input type=hidden ...> object. Remove the declaration of the txtExists ant instead type the following in the ItemCommand function
Dim exists As String = CType(e.Item.FindControl("txtExists"), TextBox).Tex

This works for me!
 
A

avnrao

hope you are doing this in ItemCommand just before accessing the txtExists
value.

txtExists = (HTMLInputHidden) e.Item.FindControl("txtExists");

Av.
 
S

simon

I found a solution wth <input type='hidden'>:
Dim exists As String = CType(e.Item.Cells(4).Controls(3),
HtmlInputHidden).Value


If you have <asp:TextBox id=txtExists runat=server visible=False > then this
control is not rendered (because of visible=false)
so you can't read Dim exists As String =
CType(e.Item.FindControl("txtExists"), TextBox).Text

I think so.

Thank you,
Simon

Mikael Gustafsson said:
Try to use a <asp:TextBox id=txtExists runat=server visible=False
value='...'> item instead of a <input type=hidden ...> object. Remove the
declaration of the txtExists ant instead type the following in the
ItemCommand function:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top