Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Thursday, March 22, 2012

300 Data Sources... Am I doing something wrong?

In brief, here is my quandary… I have a GridView on a page with some radio buttons, a couple of check boxes, some drop downs etc. And depending on what the user selects the Grid View needs to show different columns from the database…

The easiest way I have found to do this is to have a separate Data Object for each "view", i.e. each variation of the checkboxes and radio buttons (which determine which dropdowns to use for the variables) and then bind the GridView to the specific Data Source at runtime…

It seemed like a good idea at the time, but now I have over 7 different data connections cluttering up the design view, and more to come and I feel like I am missing a better way to achieve the same results…

Does anyone have some advice for a major novice?

Here's the beginning of a large set of nested ifs, if this is the way it's done that's fine too, I'll just keep creating data sources, I just get the feeling there must be an easier way to do this..

protected void Button1_Click1(object sender, EventArgs e)

{

if (RadioButtonList1.SelectedValue == "Vendor") {

if (CheckBox1.Checked == true) {

GridView2.DataSourceID = "ObjectDataSource4";

GridView2.DataBind();

TextBox1.Text = "Search";

} else {

GridView2.DataSourceID = "ObjectDataSource1";

GridView2.DataBind();

TextBox1.Text = "Search";

}

} else if (RadioButtonList1.SelectedValue == "Store Number")

{ GridView2.DataSourceID = "ObjectDataSource2";

GridView2.DataBind();}

else {

GridView2.DataSourceID = "ObjectDataSource3";

GridView2.DataBind();

TextBox1.Text = "Search";

}

}

Any advice for a major novice would be greatly appreciated! Thanks!

Hi Maccampbell,

I don't blame you for coming up with this solution.

Its just that the VS.NET IDE team wants everything in one click that has caused you to design like this.

Well you should also know how its done the classical way.

You should have a stored procedure which would take all your related input parameters like radiobutton value etc. Based on values in the parameters you select the desired rows and pass them to the GridView.

From the gridview you just have to call the stored procedure and pass the parameters.

Check ADO.NET related articles.

Happy programming,
Anton

|||

Thanks for the response!

I have followed some of the online tutorials, and have created a Data Access Layer, which I have bound to my ObjectDataSource and then onto my GridView, and the point and click methodology works very well for using Filters, determined by a page control, what I haven't been able to find an example / tutorial about is how to use the same process but have it affect returned columns as opposed to returned results... does that make sense?

So in my Query Builder for filtering you have something like:

Select **** from **** where id = @.id

You bind the @.id to a control ex: DropDownList1.SelectedValue and this works very well... What I can't figure out how to do is:

Select Coulmn1, Column2, @.VariableColumn, from **** where id = @.id

When I try something like this I get no option to bind @.VariableColumn in the Designer, and if I try to do it on the code of the ASP Page it unbinds the ObjectDataSource from the DAL...

Is there a good tutorial out there on this? Any further suggestions? Thanks again.

Mac

|||

You can't use variables as either column names or table names.

Two approaches to this problem would be to use a dynamic query with EXEC or the equivalent stored procedure.

The other approach would involve unraveling your result like:

SELECT Column1, Column2,'LastName',LastName FROM ...

UNION ALL

SELECT Column1, Column2,'FirstName',FirstName FROM ...

UNION ALL

...

With that you can now query against it, like:

SELECT Column1,Column2,MAX(WHENFieldName=@.Column3 THEN Value ELSE '' END) AS Column3,MAX(WHENFieldName=@.Column4 THEN Value ELSE '' END) AS Column4

FROM vw_TheViewFromAbove

GROUP BY Column1,Column2

However, the second approach would be horrendously long, and slow.

|||

You could also do one of these approaches as well:

Ask for all the columns, create your gridview with all the columns bound, then selectively set the columns you don't want to visibile=false.

Databind only the key fields that don't change (Or none at all), and catch the gridview row databinding event, and fill the columns how you want in there (Much harder, but probably more efficient).

Use a combination of the above. The dynamic query with selectively setting columns to invisable or removing them should work well I would think.

|||

Motley,

Thanks very much... that would explain why I haven't seen it in any tutorials, if it can not be done!

I will attempt one of these alternate approaches instead... Thanks.

Tuesday, March 20, 2012

3 questions

1) Which one of the following is NOT a SQL Server page type?
Index, Table, Data, Text /Image, Global Allocation MAP,
2) Which one of the following is a characteristic of a Keyset-Driven Cursor?
Order is Dynamic. , Values are Dynamic., Membership is Dynamic., Keyset is built in memory, Usage of the tempdb database is reduced.
3) Which one of the following situations benefits LEAST from parallel execution?
1) Extensive aggregation in a large corporate billing application
2) Large groups of small transactions in an OLTP application
3) Multiple joins in a decision support system
4)Large sorts in a data warehouse reporting application
5)Small groups of large queries in an OLAP application
What do you think the answers are?
David G.
|||1) Which one of the following is NOT a SQL Server page type?
Global Allocation MAP
2) Which one of the following is a characteristic of a Keyset-Driven Cursor?
Values are Dynamic
3) Which one of the following situations benefits LEAST from parallel
execution?
Large groups of small transactions in an OLTP application
-- Original Message --
From: "David Gugick" <davidg-nospam@.imceda.com>
Newsgroups: microsoft.public.sqlserver.clients
Sent: Tuesday, March 01, 2005 6:11 PM
Subject: Re: 3 questions

> What do you think the answers are?
> --
> David G.
>
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OatMxPrHFHA.3500@.TK2MSFTNGP14.phx.gbl...
> What do you think the answers are?
> --
> David G.
>
|||John wrote:
> 1) Which one of the following is NOT a SQL Server page type?
> Global Allocation MAP
I think the answer to this one is a table (see Pages and Extents in BOL)

> 2) Which one of the following is a characteristic of a Keyset-Driven
> Cursor?
> Values are Dynamic
I agree with you on this one.

> 3) Which one of the following situations benefits LEAST from parallel
> execution?
> Large groups of small transactions in an OLTP application
I agree with you on this one as well.
David Gugick
Imceda Software
www.imceda.com
sql

Monday, March 19, 2012

2nd Table on Report Shifts Down

Hi

I have created a report with in reporting services with 2 tables. One at the top of the page, and one at the bottom. The one at the top will contain payment details which grows depending on how many items(rows) are in my dataset and the table at the bottom contains a cheque layout - for ex. Pay Mr X, Date...etc. This table will fill out boxes on a cheque

My problem is that the table at the bottom(cheque) is being shifted down depending on what's in the top table(payment items). I need that the cheque table remain in the sample position, independent from what is in the payment table.

Has anybody ever encountered this problem and have a solution to it?

Thanks in advance.Hi

managed to solve this problem using Sub Reports. I put the top table into a sub report and it works fine.

The only problem is when adding another level of grouping in the Table within the sub report, the initial problem emerges again.

Any other ideas?

|||Try putting the table inside of a rectangle (invisible border). The table should "consume" the space in the containing rectangle before pushing the other table down. However, there is no guarantee that the bottom table will stay on the page if the top grows too much.

Tuesday, March 6, 2012

2005 WebForm ReportView Toolbar Page Count Font Color Setting?

I am using RS 2005 ReportViewer in an ASP.NET 2.0 page.
The Toolbar Page Count, "of xx", has a Font Color of White and does not show
up very well on the default Back Color.
It appears to be inheriting it from the StyleSheet Color for BODY. If I
change that Color, the Page Count Color changes to the new color.
Is there a setting for this Page Count Font Color?
I have tried FontColor in the control, but this doesn't work.
I even tried wrapping the control in a TABLE or SPAN but not luck.
Thanks,
DougI did come up with a work around by using some injection in the ReportViewer
Control's Font-Names Property.
Font-Names="Verdana"
becomes
Font-Names="Verdana;color:Black"
Doug
"Douglas J. Badin" <DJBadin@.newsgroups.nospam> wrote in message
news:%23usrNmi4GHA.2264@.TK2MSFTNGP06.phx.gbl...
>I am using RS 2005 ReportViewer in an ASP.NET 2.0 page.
> The Toolbar Page Count, "of xx", has a Font Color of White and does not
> show up very well on the default Back Color.
> It appears to be inheriting it from the StyleSheet Color for BODY. If I
> change that Color, the Page Count Color changes to the new color.
> Is there a setting for this Page Count Font Color?
> I have tried FontColor in the control, but this doesn't work.
> I even tried wrapping the control in a TABLE or SPAN but not luck.
> Thanks,
> Doug
>

Sunday, February 19, 2012

2005 Management Studio: Jobs Details (summary page)

I'm missing the info I got from EM on jobs, in the summary page, e.g. when a
job was last run, success/failure, scheduled, enabled, etc.
I don't see any way to add these columns on the summary page in Managment
Studio, am I missing something, or is this info not available there?
Thanks
Tom
TomT wrote:
> I'm missing the info I got from EM on jobs, in the summary page, e.g. when a
> job was last run, success/failure, scheduled, enabled, etc.
> I don't see any way to add these columns on the summary page in Managment
> Studio, am I missing something, or is this info not available there?
> Thanks
> Tom
Tom,
Go to Object Explorer - SQL Server Agent - Jobs. Here you can right
click on the job and get the job history, properties etc. Pretty much
the same as you're used to on EM but it looks a bit different.
HTH
Regards
Steen
|||Hi Tom,
In SQL Server 2005, we use Job Activity Monitor to see following items
Name - Name of the job.
Enabled - Whether the job is enabled (yes) or not enabled (no).
Status - Current status of the job.
Last Run Outcome - Job status when last run.
Last Run - Date and time job was last run.
Next Run - Date and time the job is next scheduled to run.
Category - The job category assigned to the job.
Runnable - Yes if the job can be run; No if the job cannot be run.
Scheduled - Yes if the job is assigned to a job schedule; No if the job has
no schedule.
For more detailed information, check BOL or MSDN topic
Job Activity Monitor
http://msdn2.microsoft.com/en-us/library/ms188272.aspx
How to: View Job Activity (SQL Server Management Studio)
http://msdn2.microsoft.com/en-us/library/ms187449.aspx
Monitoring Job Activity
http://msdn2.microsoft.com/en-us/library/ms188272.aspx
How to: Set Up the Job History Log (SQL Server Management Studio)
http://msdn2.microsoft.com/en-us/library/ms175072.aspx
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.