473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problems with HtmlControls.HtmlInputText & datalist Update

I'm trying to do a simple update of data but I can't get the code right.

It's a datalist control that has the update/cancel/delete subroutines.

Here's the broken down datalist aspx code (just the EditItemTemplate part):
<EditItemTemplate>
<table cellpadding="10" style="font: 12PT Bookman Old Style">
<tr>
<td><b>Name:</b><input id="edit_name" type="text"
value='<%#DataBinder.Eval(Container.DataItem, "name")%>' runat="server"
/></td>
</tr>
<tr>
<td>
<asp:Button ID="button2" CommandName="Update" runat="server"
Text="Update" />
<asp:Button id="button3" CommandName="Cancel" runat="server"
Text="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>

And here's my update command subroutine:

Sub DL1_Update(ByVal sender As Object, ByVal e As
DataListCommandEventArgs)
Dim TKEY As String

TKEY = DL1.DataKeys(e.Item.ItemIndex)

Dim test As String =
e.Item.FindControl("edit_name").Controls.ToString
test = e.Item.FindControl("edit_name").ToString

Dim test2 As System.Web.UI.HtmlControls.HtmlInputText
test2 = e.Item.FindControl("edit_name")

Dim SQL As String
SQL = "UPDATE phonetest SET name = '" & test2.ToString & "'
WHERE ID = " & TKEY
Dim objConnection As SqlConnection
objConnection = New
SqlConnection(ConfigurationManager.AppSettings("te sts"))
Dim objCommand As New SqlCommand(SQL, objConnection)
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()

DL1.EditItemIndex = -1
PopulateList()
End Sub

I've tried both test and test2 (see code above) for the text part of my
update sql statement. However, it doesn't appear to matter. The only
thing that actually get sent back to the server is this text:

System.Web.UI.HtmlControls.HtmlInputText

When I click update, the text above is what gets written to the table
instead of whatever it is I type.

So, I just need to know how to set the text I type into the text box
into a variable so I can place that into my SQL text.

TIA,
Jim
Sep 12 '06 #1
0 1151

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vjmehra | last post by:
I have a datalist within a datagrid and I am having trouble trying to get the update command working. I am only using the one for the datagrid, but this should also update the datalist, however...
2
by: Chris Barrow | last post by:
Hi everyone, Does anyone know if there is a problem populating a system.web.ui.htmlcontrols.htmlinputtext control when the control's type is set to "password?" I am attempting to retreive a...
3
by: Steven.Dahlin | last post by:
I have a situation where the htmlcontrols are not reflecting changes made to the textboxes when the page is returned to the server. I have a set of textboxes configured like so: <input...
3
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
2
by: Laura K | last post by:
I would like to create a nested datalist inside the selecteditemtemplate of a datalist. My hope is that when a user clicks on a link a set of child links is displayed. For example if the user...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
0
by: Jim in Arizona | last post by:
Is there an easier way to make a datalist aware of line breaks within text fields? I have a text box that users can type into. If they press the enter key a few times, VB sees this as a vbCrLf....
2
tjc0ol
by: tjc0ol | last post by:
Hi guys, Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.