Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 3rd, 2007, 08:55 PM
weiwei
Guest
 
Posts: n/a
Default populate record from db into web form textfield

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;Pa ssword=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>

  #2  
Old January 3rd, 2007, 09:15 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: populate record from db into web form textfield

weiwei wrote:
Quote:
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" %>
---------canned
reply-------------------------------------------------------------
There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.
------------------------------------------------------------------------
-----------------

You might want to clarify the symptoms you are experiencing when you
post there. What happens when you run this page?



--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


  #3  
Old January 4th, 2007, 10:25 PM
Chad.Burggraf@gmail.com
Guest
 
Posts: n/a
Default Re: populate record from db into web form textfield

On Jan 3, 1:46 pm, "weiwei" <weihuang...@gmail.comwrote:
Quote:
<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>
You cannot have more than 1 form element on an ASP.NET page. According
to the above code you're generating a form element for each row in your
dataset.

Cheers
Chad

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles