Click here to Skip to main content
15,890,932 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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.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
Posted
Updated 3-May-12 3:29am
v2

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900