中继器控制中的选定项目 [英] Selected items in repeater control
问题描述
protected void btnPDF_Click(object sender, EventArgs e)
{
DataTable _dtpdf = new DataTable();
_dtpdf = (DataTable)(ViewState["TempData"]);
DataTable _dtimport = new DataTable();
try
{
string memberno = "1002,1003";
DataRow[] rowsfound = _dtpdf.Select("MEMBERNO('" + memberno + "')");
_dtpdf.Clear();
foreach (DataRow item in rowsfound)
{
_dtimport.ImportRow(item);
}
int j = _dtpdf.Rows.Count;
Rpt_Company.DataSource = _dtpdf;
Rpt_Company.DataBind();
}
catch (Exception ex)
{
throw ex;
}
1.在上面的编码中,我创建了一个数据表
DataTable _dtpdf = new DataTable();
2. _dtpdf =(DataTable)(ViewState ["TempData"]);
并分配给viewstate
3.字符串memberno ="1002,1003";
手动在源页面中给这2个数字,我在转发器控件中仅选择这2个项目
4. DataRow [] rowsfound = _dtpdf.Select("MEMBERNO(""+ memberno +"''));
选定的项目应存储在rowsfound中……但没有发生.....请帮帮我
我正在将对象引用未设置为对象的实例
请告诉任何逻辑或纠正我的错误
1.in the above coding i created a datatable
DataTable _dtpdf = new DataTable();
2. _dtpdf = (DataTable)(ViewState["TempData"]);
and assigned to the viewstate
3. string memberno = "1002,1003";
manually i am giving this 2 numbers in the source page and i am selecting only these 2 items in the repeater control
4. DataRow[] rowsfound = _dtpdf.Select("MEMBERNO(''" + memberno + "'')");
selected item should be stored in rowsfound ......but it is not happening.....PLease help me
i am getting object refernce not set to an instance of a object
PLease tell any the logic or correct my error
推荐答案
尝试_dtpdf.Select("MEMBERNO = 1002")可以正常工作吗?
当您尝试_dtpdf.Select("MEMBERNO = 1002或MEMBERNO = 1003")时,它起作用了吗?
如果要使用in子句,请尝试使用本文.
使用带"IN"的Linq On数据表进行过滤不在"条款 [ ^ ]
Did it work when you try _dtpdf.Select("MEMBERNO=1002")?
Did it work when you try _dtpdf.Select("MEMBERNO=1002 or MEMBERNO=1003")?
If you want to use in clause, try this article.
Filter Using Linq On datatable with "IN" and "Not In" Clause[^]
这篇关于中继器控制中的选定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!