TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
navin thangaraj
NA
44
0
how to display data in html table
Feb 5 2010 1:59 AM
hi ,
i am a new to c#..could you help me out to solve this issue..
i am retriving a value from database and then i have to display it in html table.
the table contains 25 columns..the code :
default.aspx.cs
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.Data.SqlClient;
using
System.Data.OleDb;
using
System.Text;
public
partial
class
_Default
: System.Web.UI.
Page
{
protected
void
Page_Load(
object
sender,
EventArgs
e)
{
}
public
OleDbConnection
con =
new
OleDbConnection
(System.Configuration.
ConfigurationManager
.AppSettings[
"ConStr"
]);
protected
void
Button1_Click1(
object
sender,
EventArgs
e)
{
try
{
con.Open();
string
srtSQry =
"Select mobile, branch_code from branch_master Where branch_id =('"
+ branch_id.Text +
"') "
;
OleDbDataReader
client_idReader;
OleDbCommand
Comm =
new
OleDbCommand
(srtSQry, con);
client_idReader = Comm.ExecuteReader();
while
(client_idReader.Read() ==
true
)
{
client_name.Text =
Convert
.ToString (client_idReader[
"mobile"
]);
client_pan.Text =
Convert
.ToString (client_idReader[
"branch_code"
]);
}
client_idReader.Close();
}
catch
(
Exception
ex)
{
}
finally
{
con.Close();
}
}
}
default.aspx:
<%
@
Page
Language
="C#"
AutoEventWireup
="true"
CodeFile
="Default.aspx.cs"
Inherits
="_Default"
%>
<!
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
>
Table display
</
title
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server">
Enter Branch ID :
<
asp
:
TextBox
ID
="branch_id"
runat
="server"></
asp
:
TextBox
>
<
br
/>
<
br
/>
<
asp
:
Button
ID
="Button1"
runat
="server"
Height
="49px"
onclick
="Button1_Click1"
Text
="click me"
Width
="201px"
/>
<
br
/>
<
div
id
="txtHint">
Client Name :
<
asp
:
TextBox
ID
="client_name"
runat
="server"></
asp
:
TextBox
>
<
br
/>
Client PAN No:
<
asp
:
TextBox
ID
="client_pan"
runat
="server"></
asp
:
TextBox
>
<
br
/>
</
div
>
</
form
>
<
script
type
="text/javascript">
function
stateChanged()
{
if
(xmlhttp.readyState==4)
{
document.getElementById(
"txtHint"
).innerHTML=xmlhttp.responseText;
}
}
function
GetXmlHttpObject()
{
if
(window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return
new
XMLHttpRequest();
}
if
(window.ActiveXObject)
{
// code for IE6, IE5
return
new
ActiveXObject(
"Microsoft.XMLHTTP"
);
}
return
null
;
}
/*
for entering only numbers in the text box */
document.getElementById(
"branch_id"
).onkeypress=
function
(e){
var
e=window.event || e
var
keyunicode=e.charCode || e.keyCode
//Allow alphabetical keys, plus BACKSPACE and SPACE
return
(keyunicode>=48 && keyunicode<=57)?
true
:
false
}
</
script
>
<
script
runat
="server">
</
script
>
</
body
>
</
html
>
webcofig:
in webcofig i have included the connection string
Reply
Answers (
7
)
Scrolling for an Image BOX
Handle Windows operating system window creation events