Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview show record based on value in database

Status
Not open for further replies.

lunchbox88

Programmer
Feb 17, 2004
208
US
ASP.NET/VB.NET 2.0

I have a webform that has a gridview bound to a stored proc using the SQLDataSource. I need to set the visible property of records based on a value in the datasource. My initial thougt (when I thought it was bound to a dataset) was to do a select against the datatable, and bind to the result of that.

I'm trying to have to change as little of the existing code as possible. Any thoughts on the best way to accomplish this?

Thanks
 
You should change the sql that pulls the data back. There is no reason to pull back data that you will not show.
 
Here's why I'm not sure it's that simple. What I need is to display a "master site" record. What they want to see is this "master site" record, and then have the ability to click a link/button/whatever next to the record to have the "child site" record(s) associated with that "master site" open in a separate window.

Currently, the stored proc returns the master, with the child listed underneath it. My thought was to designate a "display level" to allow for filtering between the master and child sites. That way, I could filter the data table in to two; one for master and one for child. Then, when they click the button/link/whatever, I can just pass the child datatable to the new window.

I would rather not make a huge change to the stored proc as it is currently 19 pages long and full of UNION ALL statements that populate a temp table, and then more select statements are created on the fly against that temp table (based on parameters) and that is what's returned. I didn't write any of this app so far, I was just told to get it working as quickly as possible.

Thanks
 
In that case, get rid of the SqlDataSource. That will only cause you more headaches. Get your resutls back into a dataset with your datatables, and then you can do exactly what you were saying, selecting from the datatable.
 
That's what I was thinking I was going to have to do. I've never used a gridview control, and generally don't work with bound controls, so I wanted to make sure I wasn't missing something.

Thanks!
 
I would rather not make a huge change to the stored proc as it is currently 19 pages long and full of UNION ALL statements that populate a temp table, and then more select statements are created on the fly against that temp table (based on parameters) and that is what's returned. I didn't write any of this app so far, I was just told to get it working as quickly as possible.
That sounds like the perfect reason to look at creating a new procedure for this task (19 pages sounds well over the top for something this simple). You obviously don't need to do all of the processing every time, so now is the time to create a new procedure that only returns the relevant information. I'd set it up to just return the header records and have a seperate procedure to return the child records when and if they are asked for.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top