如何在ASP.NET页面中打印表格数据 [英] How to print table data in asp.net page

查看:58
本文介绍了如何在ASP.NET页面中打印表格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表数据.我已经将数据插入到雇员表之类的一个表中.现在,当我单击插入按钮时,它将插入数据.但是之后,我想在下一个asp页面中显示更新的表数据.我是.net的新手,请向我提供简单的代码,以便我能轻松理解.我想将表数据打印在页面中,而页面本身正在加载(在页面加载中,我想编写它的代码).请提供简单的解决方案.

I have one table data.I have inserted data into one table like employee table.Now when i click on insert button ,it will insert data.But after that i want to show the updated table data in next asp page.as I am new to .net please provide me simple code so that i can eaisly understand.I want to print the table data in a page ,while it is loading itself(in the page load i want to write the code of it).Please provide simple solution.

推荐答案

使用选择查询....
受保护的void Page_Load(对象发送者,EventArgs e)
{

SqlConnection con =新的Sqlconnection("Data Source =.\\ sqlexpress; Initial Catalog = DatabaseName; Integrated Security = True");
SqlCommand cmd =新的SqlCommand(从雇员中选择*",con);
SqlDataReader dr = cmd.ExecuteReader()''
While(dr.Read())
{
TextBox1.Text = dr.GetValue(0).ToString();//雇员表的第一个值
TextBox2.Text = dr.GetValue(1).ToString();//雇员表的第二个值
TextBox3.Text = dr.GetValue(2).ToString();//雇员表的第三个值
.
.
.
}
}
尝试使用此代码....
using select Query....
protected void Page_Load(object sender, EventArgs e)
{

SqlConnection con=new Sqlconnection("Data Source=.\\sqlexpress;Initial Catalog=DatabaseName;Integrated Security=True");
SqlCommand cmd=new SqlCommand("Select * from employee",con);
SqlDataReader dr=cmd.ExecuteReader()''
While(dr.Read())
{
TextBox1.Text=dr.GetValue(0).ToString();//first value of a employee table
TextBox2.Text=dr.GetValue(1).ToString();//second value of a employee table
TextBox3.Text=dr.GetValue(2).ToString();//third value of a employee table
.
.
.
}
}
Try This Code....


这篇关于如何在ASP.NET页面中打印表格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆