ASP.NET - please any help?? - Asked By mani on 14-Dec-11 01:32 AM

hi..please anybody helpme..
i have unique number values in my table..
and i will getany number of that value in session..
and i have to read all those record of that values from table and bind it in gridview...
Jitendra Faye replied to mani on 14-Dec-11 01:40 AM
Use this code-

protected void GetDetails_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection("con string ");
SqlDataAdapter da;
string mySQL = "SELECT * FROM emptable where empid='" + Convert.ToString(Session["id"]) + "'";
da = new SqlDataAdapter(mySQL, con);
DataSet ds = new DataSet();

//Now Filling Details-


Try this code and let me know.

mani replied to Jitendra Faye on 14-Dec-11 01:43 AM
hi i have multiple unique value in that session separated with comma,,
i need to split it and get all those record from table..
dipa ahuja replied to mani on 14-Dec-11 02:27 AM
You have to use the IN clause

For eX;

void getReuslt()
  string Ids = Session["values"].ToString();
  SqlDataAdapter da = new SqlDataAdapter("select * from tabl1 where Ids IN(" + Ids + ")""connString");
  DataTable dt = new DataTable();
  //bind Gridview

Jitendra Faye replied to mani on 14-Dec-11 03:33 AM
You can split like this-

string s = "a,s,d,f,g";

string[] words = s.Split(',');
foreach (string word in words)

Try this and let me know.