c# - Checking ID against Access Table and looping through an SQL statement -


i posted question yesterday selecting item in gridview , adding list, found solution for, takes value of gridview, in case id number , outputs them on page in gridview.

my question is, possible check value of id against table in access database display more information product?

i have following code on basket page:

    protected void page_init(object sender, eventargs e)     {         if (session["cartsess"] != null)         {             list<basketclass> cart = (list<basketclass>)session["cartsess"];              foreach (basketclass bookid in (list<basketclass>)session["cartsess"])             {                 gridview1.datasource = cart;                  gridview1.databind();                 accessdatasource1.selectcommand = "select [bookid], [book_title] [tblbook] [bookid]=" + bookid;             }         }     } 

the problem is, returns 1 value based upon last 1 user has chosen, there way loop through each of them keep adding new gridview have placed on page bound accessdatasource1?

i try like:

string items = ""; string sql = "select [bookid], [book_title] [tblbook] [bookid] in ("; foreach (basketclass bookid in (list<basketclass>)session["cartsess"]) {     items += bookid & ","; } //remove trailing "," items.remove(str.length - 1, 1); gridview1.datasource = cart; gridview1.databind(); accessdatasource1.selectcommand = sql & items & ")"; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -