sharris_glascol
asked on
Only show certain Fields in a datagridview
How do I only display certain fields in sql query on a aspx c# page? see code below using this in a load pdf page.
}
void LoadData()
{
var st = from s in db.Design_Tables select s;
GridView1.DataSource = st;
GridView1.DataBind();
}
void LoadData()
{
var st = from s in db.Design_Tables select s;
GridView1.DataSource = st;
GridView1.DataBind();
ASKER
can a where clause be done here as well?
For Eric's proposed solution, don't forget to convert your result to a list; e.g. -
var st = (from s in db.Design_Tables select new { s.Field1Name, s.Field2Name }).ToList();
-saige-
Sure this is a LINQ query:
var st = from s in db.Design_Tables where s.Field1Name == "yourvalue" select new { s.Field1Name, s.Field2Name };
Yes you can add a where clause as well; e.g. -
var st = (from s in db.Design_Tables where s.FieldToCompare == "some value" select new { s.Field1Name, s.Field2Name }).ToList();
-saige-
ASKER
that works but in the where clause how can I get it to == a textbook inside of the page?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked!! When I publish this to the web when I select my link button to the pdf folder it doesn't find it. When I run locally on my pc if finds it, I think it's a path issue where still looking at local HD instead out on the server.
this is how the string is laid out
int rowindex = ((GridViewRow)((sender as Control)). NamingContainer).RowIndex;
string filelocation = Gridview1.Rows[rowindex].c ells[2].te xt;
string FilePath = Server.MapPath("~/" + filelocation);
...any ideas??
this is how the string is laid out
int rowindex = ((GridViewRow)((sender as Control)). NamingContainer).RowIndex;
string filelocation = Gridview1.Rows[rowindex].c
string FilePath = Server.MapPath("~/" + filelocation);
...any ideas??
I am not a web expert. It can be many things like missing privileges on the folder.
If the LINQ query is working, it is a brand new question then.
If the LINQ query is working, it is a brand new question then.
Open in new window