Data display in textbox

dear friends i want show record from database to textbox but i cannot do it shows nothing here is code newuser.aspx.vb

Imports System.Data.OleDb
Partial Class Edit_NewUser
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load



    Dim vparam, dbconn, sql, dbcomm, dbread, objdatareader


    dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("db1.mdb"))
    dbconn.Open()
    vparam = Request.QueryString.Get("un")
    sql = "SELECT * FROM user_login where user_name='" & vparam & "'"
    dbcomm = New OleDbCommand(sql, dbconn)
    dbread = dbcomm.ExecuteReader()
    Repeater1.DataSource = dbread
    Repeater1.DataBind()


    dbread.Close()
    dbconn.Close()
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

End Sub

End Class

and in asp html file
<%@ Page Language=“VB” AutoEventWireup=“false” CodeFile=“Edit_NewUser.aspx.vb” Inherits=“Edit_NewUser” %>
<%@ Import Namespace=“System.Data.OleDb” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=“http://www.w3.org/1999/xhtml” >
<head runat=“server”>
<title>Untitled Page</title>
</head>
<body>
<form id=“form1” runat=“server”>
<div>
<asp:Repeater ID=“Repeater1” runat=“server”>
</asp:Repeater>
 </div>
<br />
<table>
<tr>
<td style=“width: 121px; height: 26px”>
<span style=“font-size: 16pt”><strong>New</strong> <strong>User</strong></span></td>
<td style=“width: 157px; height: 26px”>
<span style=“font-size: 16pt”><strong>             
         <span style=“color: #006633”>New</span></strong></span></td>
</tr>
<tr>
<td style=“width: 121px; height: 35px”>
</td>
<td style=“width: 157px; height: 35px”>
</td>
</tr>
<tr>
<td style=“width: 121px”>
<strong>First Name</strong></td>
<td style=“width: 157px”><itemtemplate></itemtemplate>
<asp:TextBox ID=“TextBox1” runat=“server” ></asp:TextBox></td>
</itemtemplate><asp:TextBox id=“txtName” Runat=“server”
/></tr>
<tr>
<td style=“width: 121px”>
<strong>Last Name</strong></td>
<td style=“width: 157px”>
</td>
</tr>
<tr>
<td style=“width: 121px; height: 21px”>
<strong>Email</strong></td>
<td style=“width: 157px; height: 21px”>
</td>
</tr>
<tr>
<td style=“width: 121px”>
<strong>User Name</strong></td>
<td style=“width: 157px”>
</td>
</tr>
<tr>
<td style=“width: 121px”>
<strong>Password</strong></td>
<td style=“width: 157px”>
</td>
</tr>
<tr>
<td style=“width: 121px; height: 21px;”>
</td>
<td style=“width: 157px; height: 21px;”>
</td>
</tr>
<tr>
<td style=“width: 121px”>
</td>
<td style=“width: 157px”>
<asp:Button ID=“Button1” runat=“server” Text=“Button” /></td>
</tr>
<tr>
<td border=“0” style=“width: 121px”>
</td>
<td border=“0” style=“width: 157px”>
</td>
</tr>
</table>
</form>
</body>
</html>
plz correct it i want to show record in textbox but it shows blank plz provide me the code

Show the link you’re using to access the page.

Ok, well I see a few problems here:

  1. There is not <ItemTemplate> in your repeater
  2. Further down the page you have a <ItemTemplate> tag with nothing in it, and not in a repeater tag.
  3. Then you have a closing </ItemTemplate> after the textbox with no opening tag.
  4. You are not setting the text for the textbox in and ItemDataBound event or on the front-end.
  5. Your query is opening up your code for sql injection attack, you should look at using parameters

You must have the following:


<asp:Repeater runat="server" id="Repeater1" OnItemDataBound="Repeater1_ItemDataBound">
   <ItemTemplate>
      <asp:TextBox ID="TextBox1" runat="server" />
   </ItemTemplate>
</asp:Repeater>

Everything in the repeater ItemTemplate, will be repeated for each record

Then in the code behind, have the method to handle the OnItemDataBound. Get the textbox and set its text value.

try

<ItemTemplate>
<asp:TextBox ID=“TextBox1” runat=“server” Text=‘<%# Eval(“ColoumnName”)%>’ />
</ItemTemplate>

to display the text from the database,

why i need itemtemplate tag i have to show only 1 records at a time into text box in vb we uses text1.text=rs!column_name in asp.net bind textbox wht i use

I, uh … am not … hmm. What??

I do not understand what you mean. A repeater shows 1 item for each record in your dataset. If you only have 1 textbox and only 1 record all the time. Then you need to not used a repeater at all and on the codebehind, read the from the reader and apply it to the text of the textbox

there r three text boxes named txtfname, txtlname, txtpassword n in database field f _name,l_name,u_password now i want to show that particular record of all field into 3 textboxes i need code

Off Topic:

Careful, you don’t want to get a reputation as a Help Vampire

Like I said, on the code-behind page, create a SqlDataReader. Then while it is reading apply the values to the textboxes that is not in a repeater. Google for the code, I do not know VB that well, and besides, I gave you a a direction and it would be better for you to figure it out by yourself instead of someone just giving you the code.

Give a man fish and feed him for a day, teach a man to fish and feed him for a life time.

erll code is ayyached with file n i m using access database

Google: “SqlDataReader VB.NET.” That will give you the code you need and fix the points I mentioned earlier

Hi Friends well i m developing an application into asp.net database is access

now i want to show a particular record into 1 textbox names txtbox1 here is code plz give me code that i can show record into textbox

Imports System.Data.OleDb

Partial Class Default123
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim vparam, dbconn, sql, dbcomm, dbread

dbconn = New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;data source=” & Server.MapPath(“abcd.mdb”))

dbconn.Open()
vparam = Request.QueryString.Get(“un”)
sql = "SELECT * FROM user_login where user_name=vparam "
dbcomm = New OleDbCommand(sql, dbconn)

dbread = dbcomm.ExecuteReader()
Repeater1.DataSource = dbread
Repeater1.DataBind()

dbread.Close()
dbconn.Close()
End Sub

End Class

here is final code still not getting answers correctly

why are you using a repeater if you just want to show record in textbox? NightStalker-DNS already told you how to go about it