Hi,

im trying to set a row filter based one fixed paramater (locationID) and a second paramater on a session variable - im not an expert in C# at all, but i think what i have done should work? Can anyone see anything wrong / offer suggestions please? :)

try
        {

            connection.Open();

            string sqlStatement = "SELECT * FROM SI";

            SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);

            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
            
            sqlDa.Fill(dt);
            
            string pID = Convert.ToString("Session[pageId]");
                       
            if (dt.Rows.Count > 0)
            {

                DataView dv = new DataView(dt); 
                dv.RowFilter = "locatID = 1, PageId =" + pID + "";
                GridView1.DataSource = dv;
                GridView1.DataBind();
                dv.RowFilter = "locatID = 2, PageId =" + pID + "";
                GridView2.DataSource = dv;
                GridView2.DataBind();
                dv.RowFilter = "locatID = 3, PageId =" + pID + "";
                GridView3.DataSource = dv;
                GridView3.DataBind();


            }

any help would be most appreciated :)

thanks

btw i keep getting the error "Syntax Error Exception was unhandled by user code"

Use boolean operators. - and , or

dv.RowFilter = "locatID = 1 and  PageId =" + pID;

After filtering how can i show all the records again?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.