views:

63

answers:

2

Hello,

I want to check a condition in a grid view e.g.

if(loginid.equels('admin')) query = select * from memberlist; else query = select * from memberlist where memberid like 'operator%';

depending on the query ther grid view will display the listof members and also where to put this code in .cs or .aspx and how?

Regards

Indranil

A: 

The place to put this kind of logic is in the cs code behind file. You can put it in the page load, and then set the DataSource of the grid to the memberlist and then call DataBind. Hope this is what your asking for?

Marwan
yep but it would be better if u could site an example please:)
Indranil Mutsuddy
A: 

Hi, Write this code in the place where u need to check d condition and it would work.

 string query = string.empty;
if(loginid.equels('admin')) 
{
    query = "select * from memberlist";         
}
else
{
    query = "select * from memberlist where memberid like 'operator%'";
}
SqlDataAdapter da = new SqlDataAdapter(query,sqlCon);
DataSet ds = new DataSet("aa");
da.Fill(ds, "ww");
gvData.DataSource = ds.Tables["ww"];
gvData.DataBind();
GayaMani