How to display records inside text box using asp.net
well i am trying to put the records of 2 diffrent tables in text box and putting a edit button next to it but i do not know how to do it in asp.net. I already learned how to display the records but do not know how to put them in text box and an edit box next to it ! i be happy if some one help me here. Thanks
Here is my code :
----------------
<%@ Page enableViewState="False" Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="vb" runat="server">
Sub Page_Load(Sender As Object, E as EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbDataAdapter
Dim strConnect As String
Dim strCommand As String
Dim DataSet1 As New DataSet
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnect += "Data Source=C:\Inetpub\wwwroot\"
strConnect += "db\"
strConnect += "\TENNIS DATABASE.mdb;"
strConnect += "Persist Security Info=False"
Response.Write("Viewing Player Record No:" +Request.QueryString("person_id")+"")
strCommand = "SELECT * FROM players where playerno = " +Request.QueryString("person_id")+";"
objConnection = New OleDbConnection(strConnect)
objCommand = New OleDbDataAdapter(strCommand, objConnection)
objCommand.Fill(DataSet1, "players")
DataGrid1.DataSource=DataSet1.Tables("players").DefaultView
DataGrid1.DataBind()
'second select
Dim strCommand2 As String
Dim DataSet2 As New DataSet
strCommand2 = "SELECT * FROM PENALTIES where playerno = " +Request.QueryString("person_id")+";"
objConnection = New OleDbConnection(strConnect)
objCommand = New OleDbDataAdapter(strCommand2, objConnection)
objCommand.Fill(DataSet2, "PENALTIES")
DataGrid2.DataSource=DataSet2.Tables("PENALTIES").DefaultView
DataGrid2.DataBind()
end sub
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server" />
<br>
<br>
<asp:DataGrid id="DataGrid2" runat="server" />
</body>
</html>
Re: How to display records inside text box using asp.net
To add edit button, you would need to go to the property builder of the datagrid and a button column and add the edit, update and cancel one..
To show data in a textbox, try setting the textbox text property to the datarow value for that field
ie
myTextBox.Text = Dataset1.Tables("players" ).Rows(i).Item("fieldname")
:thumb:
Re: How to display records inside text box using asp.net
Quote:
Originally Posted by ninster
To add edit button, you would need to go to the property builder of the datagrid and a button column and add the edit, update and cancel one..
To show data in a textbox, try setting the textbox text property to the datarow value for that field
ie
myTextBox.Text = Dataset1.Tables("players" ).Rows(i).Item("fieldname")
:thumb:
well i am not using any development sofware. could u show me the code.?Thanks