Link to home
Create AccountLog in
Avatar of j-w-thomas
j-w-thomas

asked on

getting value of a text box in a datalist

Hi,

I have searched the solutions and my code seems to be right, but still not working.

I have a datalist with a textbox in it that starts blank when loaded and I want to capture the value entered by a user.

on the click no value is carried back and I have done things similiarly before but can't seem to figure out why this one is not working. I have even tried to loop through the datalist but still nothing.

Also, if I could change the link to a button that would be good, but it always raises the validation error.

<asp:DataList ID="dlFeature" runat="server" DataKeyField="ID" OnDeleteCommand="dl_Asap">
&#9;<headertemplate>
&#9;&#9;<table style="font-size:12px; margin:0; padding:0;">
&#9;</headertemplate>
&#9;<itemtemplate>
&#9;&#9;&#9;<tr>
&#9;&#9;&#9;&#9;<td height="20" align="center">Enter your email </td>
&#9;&#9;&#9;</tr>
&#9;&#9;&#9;<tr>
&#9;&#9;&#9;&#9;<td height="25" align="center">
&#9;&#9;&#9;&#9;&#9;<asp:TextBox ID="txtPhoneEmail" runat="server" Columns="14" />
&#9;&#9;&#9;&#9;&#9;<asp:LinkButton ID="linkInterested" runat="server" CssClass="LinkFeature" Text="I'm Interested!" CommandName="Delete" />
&#9;&#9;&#9;&#9;</td>
&#9;&#9;&#9;</tr>
&#9;</itemtemplate>
&#9;<footertemplate>
&#9;&#9;</table>
&#9;</footertemplate>
</asp:DataList>

------------ code behind ----------------------
Sub dl_Asap(s As Object, e As DataListCommandEventArgs)

intIndex = dlFeature.DataKeys(e.Item.ItemIndex)
strPhone_Email &= CType(e.Item.FindControl("txtPhoneEmail"), TextBox).Text&#9;

' i have tried both of these and can't get the value of the user's entry in text box

for each DLI in dlFeature.Items
&#9;intIndex = dlFeature.DataKeys(e.Item.ItemIndex)
&#9;strPhone_Email &= CType(e.Item.FindControl("txtPhoneEmail"), TextBox).Text&#9;&#9;&#9;&#9;&#9;&#9;
next

End Sub
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Hi,
Make sure that you are using the value of  strPhone_Email

please try this

Sub dl_Asap(s As Object, e As DataListCommandEventArgs)

strPhone_Email &= CType(e.Item.FindControl("txtPhoneEmail"), TextBox).Text      
Response.Write(strPhone_Email)
End Sub

Or
Sub dl_Asap(s As Object, e As DataListCommandEventArgs)
for each DLI in dlFeature.Items
      intIndex = dlFeature.DataKeys(e.Item.ItemIndex)
      strPhone_Email &= CType(e.Item.FindControl("txtPhoneEmail"), TextBox).Text                                    
next
Response.Write(strPhone_Email)
End Sub
Avatar of j-w-thomas
j-w-thomas

ASKER

Nothing, no resposne at all...very confusing
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
thanks I will test those out and try to figure out what i was missing...I have done it before and I cannot see why this time would not work...

Thanks again and I will get back to you
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.