populate record from db into web form textfield

W

weiwei

Hi
I am trying query the data from db and populate in the web form's
textbox field. so far I cannot put that
record into the text field box. anyone has idea on that, below is my
sample code
thanks in advance

<%'@ Page Language="VB" AutoEventWireup="false"
CodeFile="modifyuser.aspx.vb" Inherits="modifyuser" %>
<script runat="server">
Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)


Dim myConn As New
Data.OleDb.OleDbConnection("Provider=SQLOLEDB.1;Password=xxxxxxx;Persist
Security Info=True;User ID=xx;Initial Catalog=testdata;Data
Source=pub")
Dim strSQL As String = "Select * FROM test where name =
'peter'"
Dim myCommand As New Data.OleDb.OleDbDataAdapter(strSQL,
myConn)

Dim ds As Data.DataSet = New Data.DataSet()
myCommand.Fill(ds, "test")

MyDataList.DataSource = ds.Tables("test").DefaultView
MyDataList.DataBind()
End Sub
</script>

<html>
<body>
<ASP:DataList id="MyDataList" RepeatColumns="1"
RepeatDirection="Vertical" runat="server">
<ItemTemplate>
<form id="form1" runat="server">
<asp:TextBox ID="lastname" runat="server" MaxLength="50"
text="<%#DataBinder.Eval(Container.DataItem, "word")%> "></asp:TextBox>

</form>

</ItemTemplate>
</ASP:DataList>
</body></html>
 

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,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top