Find control!

liunx

Guest
Hi!
I have a problem. I really appreciate for your help.
:D
I used a datagrid template:
<asp:datagrid....
<asp:templatecolumn...
<Itemtemplate.....
<table...
<tr..
<td...
<asp: textbox id="ID"....
<input type=file id="ID1"....
.......................................................
My function (VB.Net) use the values of textbox ID and ID1:
Public Function AAA(Byval sender as Object, E as DatagridCommandEventArg)
.......
mTextbox=E.Item.FindControl("ID")
.........
the code above will get the textbox ID.
Now i want to get the value of the ID1 textbox. What should I do?
I cannot use " mTextbox=E.Item.FindControl("ID1") " because this code return a System.Web.UI.Control, and ID1 is a input box.
Anybody help me?

Thank you!!Dim strVal As String = CType(mTextbox,Textbox).Text

Something like that should work.
EricThanks Eric but the problem here is FindControl function only can find for System.Web.UI.Control.
So it cannot find ID1 textbox (<input type=file...).
Any one help me?You need to put runant="server" on your input file html element.

then you sould be able to reference it like
Dim strBtn As String = CType(e.Item.FindControl("ASDF",System.Web.UI.HtmlControls.HtmlInputFile).Value

EricHi!!! :)
Try This....

Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdCountry.UpdateCommand

objGenFunc.SqlDataSet.Tables("Country").Rows(e.Item.ItemIndex).Item("DESCR") = CType(e.Item.FindControl("txtDesc"), TextBox).Text

End Sub

Note :
1) Here " txtDesc " is your WebControl's ID.

Regards,
Milind ( Software Programmer )
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> so much folk! You're so nice!
 
Back
Top