asp.net项目中的数据集上的问题 [英] problem on dataset in asp.net project

查看:58
本文介绍了asp.net项目中的数据集上的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全局声明的数据集
我有一个组合框.
当我单击组合框时,它将获取数据并设置到数据集中..
我有一个按钮
当我单击按钮时,我需要数据集的值.
我在写

I have a dataset which has declare globally
I have a combobox.
when I click on combo box it fetch the data and set into the dataset..
I have a button
When i click on the button I need the value of dataset.
I am writing

DataRow[] dr = dsAdv.Tables[0].Select("Advisor_Id=" + cmbAdvisorNameCode.SelectedValue.ToString());





//Here dsAdv is my dataset which declare globally



但是当我单击按钮时,它显示错误,因为数据无法提取
它显示Table [0]没有值.

请帮我解决这个问题.
紧急.
否则,请告诉我,我可以在同一页面中使用全局数据集吗?

谢谢.



but when I click button then it showing error, because data could not fetch
It showing Table[0] has no value.

please help me how to solve this problem.
It''s urgent.
other wise please tell me woh can I use global dataset in the same page.

Thanks.

推荐答案

嗨...
一种方法是将数据集存储到Viewstate/Session.
Hi...
One way is you can store dataset to Viewstate/Session.


第一件事是我不喜欢在全局声明数据集的人.
无论采取什么方式,在初始化该数据集时(dsAdv = new dataset();)都变得非常重要.

一种可能是,每回发一次帖子都可能会初始化您的数据集.

真的有必要在全局范围内声明数据集吗?

为避免所有这些事情,请执行以下操作:

1.不要全局声明任何数据集.
2.不要对组合框的索引更改进行任何操作.
3.单击按钮时,创建一个数据集实例,读取组合框中选择的内容,相应地触发查询并填充数据集.
4.这样您将永远不会遇到任何意外问题.

希望对您有帮助.

〜Amol
First thing is that I don''t like people who declare dataset globally.
Any way as you have done that it becomes very important where you are initializing that dataset (dsAdv = new dataset();).

One chance is that on every post back it might initializing your dataset.

Is it really necessary to declare dataset globally ???

To avoid all these things do following:

1. Don''t declare any dataset globally.
2. don''t do anything on the index change of combo box.
3. when you click on the button, create one instance of dataset, read what is selected in the combobox, fire a query accordingly and fill the dataset.
4. This way you will never face any unexpected problem.

Hope this will help you.

~Amol


这篇关于asp.net项目中的数据集上的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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