如何使用asp.net将数据表值一个表单传递给其他表单 [英] How to pass datatable value one form to other form using asp.net

查看:79
本文介绍了如何使用asp.net将数据表值一个表单传递给其他表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我使用的是c#.net,asp.net和vs2008。



我需要使用属性或其他方法将DataTable数据传递到另一个网页。



如何做到这一点..



请建议或任何想法



问候

mukesh

Hi All,

I am using c#.net , asp.net and vs2008.

I need to pass DataTable data one webpage to another webpage using property or other method .

How to do this ..

please suggests or any idea

Regards
mukesh

推荐答案



伪代码你可以尝试



将值传递给会话



在您的第一页


pseudo code you can try

pass the value to session

on your 1st page
DataTable dt = new DataTable(); 
dt = (DataTable)Session["ss"]; 






下一页





on the next page

DataTable tb= new DataTable();
Session["ss"] = tb; 







希望这可以帮到你

快乐编码:)




hope this may help you
Happy coding:)


通过viewstate,您无法将数据从一个页面传送到另一个页面。 ViewState数据可用于pariculat页面。



对于你的案例使用会话,它会将数据从一个页面传送到另一个页面。

注意:不要忘记清除会话变量。



例如:

C#:

Through viewstate you cannot carry data from one page to another page. ViewState data will be avaialable for pariculat page.

For your case use session it will carry data from one page to another page.
Note : Don't forgot to clear session variables.

Examples :
C# :
Page 1 
DataTable dtTest =new DataTable();
Session["data"]=dtTest;

Page 2
DataTable dt=new DataTable();
dt=(DataTable)Session["data"];



VB:

Page 1


VB :
Page 1

Dim dtTest as DataTable=new DataTable()
Session("data")=dtTest

Page 2
Dim dt as DataTable=new DataTable()
dt=CType(Session("data"), DataTable)


这篇关于如何使用asp.net将数据表值一个表单传递给其他表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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