 |
|
 |
|
|
GridView DataFormatString |
|
Andy's Blog
|
By Andy Beaulieu on
1/26/2006 10:46 AM
|
|
|
Here's some fun with the ASP.NET 2.0 GridView... I'm generally more of a templated column kinda guy, but I was feeling lazy and tried to format a BoundColumn as Currency using
DataFormatString="{0:c}" ... simple enough, right? Then why doesn't it work?! Turns out you have to set the HtmlEncode attribute to False in order for the DataFormatString to take...
< asp:BoundField DataField="Amount" HeaderText="Amount" ReadOnly="True" SortExpression="Amount" DataFormatString="{0:c}" HtmlEncode="False" />
|
 |
|
Comments (2)
|
|
|
|
|
ReportViewer control - programmatically |
|
Andy's Blog
|
By Andy Beaulieu on
1/26/2006 9:08 AM
|
|
|
|
In VS2005, the report designer is great for quickly throwing together a report and binding it to an ObjectDataSource... but what if you want to do this through code for more control?
The steps are to create the report _without_ using a TableAdapter, and then manually create the data source through code (below). Note that the "rds.Name" property must be set to the "DataSetName" attribute in the report's RSDL file:
<DataSetName>DSCustomers_OutCustomers< FONT>DataSetName>
Dim dsCustomers As DSCustomers Dim oCustomers As New CCustomers()
dsCustomers = oCustomers.GetCustomers() Dim rds As ReportDataSource = New ReportDataSource ReportViewer1.LocalReport.DataSources.Clear() rds.Name = "DSCustomers_OutCustomers" rds.Value = dsCustomers.OutCustomers ReportViewer1.LocalReport.DataSources.Add(rds) ReportViewer1.DataBind()
As a second example, let's say you use a Typed DataSet and TableAdapter as a Data Source and you are creating a WindowsForms application. In the example below, a Typed DataSet has been created called "DataSet1" which queries the Customers table.
Some important things to remember:
- you need to call the Reset() method on the ReportViewer whenever you dynamically switch reports.
- you need to prefix report (RDLC) filenames with the Namespace of the project the report is in (below the namespace is "ReportViewerTest.")
reportViewer1.Reset();
DataSet1TableAdapters.CustomersTableAdapter ta1 = new DataSet1TableAdapters.CustomersTableAdapter();
DataSet1.CustomersDataTable dt1 = new DataSet1.CustomersDataTable();
ta1.Fill(dt1);
ReportDataSource rds = new ReportDataSource();
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewerTest.Report1.rdlc";
rds.Name = "DataSet1_Customers";
rds.Value = dt1;
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.RefreshReport();
|
 |
|
Comments (5)
|
|
|
|
COM+ and MSDTC hosed |
|
Andy's Blog
|
By Andy Beaulieu on
1/23/2006 11:18 AM
|
|
|
The last couple of weeks have presented some freaky problems on my end. I had a development workstation that had a hosed COM+ install (when you try to navigate to COM+/My Computer/COM+ Applications it would give an error like "An error occured while processing the last operation. Error code 80080005 - Server execution failed."
After many attempts at re-installing stuff, this seemed to work for me:
(2) reinstall MSDTC
cd %systemroot%\system32 msdtc -uninstall msdtc -install
|
 |
|
Comments (0)
|
|
|
|
Frustrating VS2005 bug |
|
Andy's Blog
|
By Andy Beaulieu on
1/16/2006 8:11 PM
|
|
|
|
I got caught with this bug back when I was playing with betas long ago... But it recently bit me again on a fresh machine with RTM VS2005 (no betas or RC's installed prior)...
When in the editor, the carriage return, delete, backspace and Edit/Cut/Copy/Paste stop functioning. Something about the toolbox windows getting focus hosed up I guess... Anyway, after trying a bunch of IDE Resets and User Settings Import/Export, this finally did it for me... Had to delete default.vsk from Docs and Settings, as this article details:
|
 |
|
Comments (0)
|
|
|
|
Mimicking a Data Repeater Control in WinForms |
|
Andy's Blog
|
By Andy Beaulieu on
1/4/2006 8:03 PM
|
|
|
|
VB6 had the cool Data Repeater which allowed you to create an ActiveX control and databind it so that it would show an instance of the user control for each row in your record set.
This cool control is missing from .NET, but it's pretty easy to mimick this functionality. Just create a Panel, set its AutoScroll property to True, and use the Controls collection to dynamically add instances of the user control. You will need to also track the Y Offset of each control you add to push down each instance.
Dim m_YOffSet As Integer = 0
Public Sub AddAddress(ByVal AddressId As Integer) Dim ucAddress1 As New ucAddress ucAddress1.Address = "123 University Lane" Panel1.Controls.Add(ucAddress1) ucAddress1.Visible = True ucAddress1.Top = m_YOffSet m_YOffSet += ucAddress1.Height End Sub
|
 |
|
Comments (0)
|
|
|
|
CBIT 2373 Class Notes |
|
Andy's Blog
|
By Andy Beaulieu on
11/16/2005 8:58 PM
|
|
|
|
Here are some notes for the CBIT 2373 class on handling multiple click events in one event handler -
Private m_nFirstValue As Decimal = -1 Private m_nSecondValue As Decimal = -1
Private Sub ButtonAny_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click, Button12.Click txtResult.Text &= CType(sender, Button).Text End Sub
Private Sub btnPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlus.Click m_nFirstValue = CType(txtResult.Text, Decimal) txtResult.Text = "" End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click m_nSecondValue = CType(txtResult.Text, Decimal) txtResult.Text = m_nFirstValue + m_nSecondValue End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click txtResult.Text = "" m_nFirstValue = -1 m_nSecondValue = -1 End Sub
|
 |
|
Comments (0)
|
|
|
|
VS2005 TableAdapters Article |
|
Andy's Blog
|
By Andy Beaulieu on
11/11/2005 5:17 PM
|
|
|
|
I have finally posted up an article I wrote on extending the new VS2005 TableAdapters into a multi-tier architecture. It is quite lengthy and shows one way of leveraging the new TableAdapter/DataSet designer in a 3-tier architecture that supports both WinForms and ASP.NET 2.0... Note that if you are creating only a WinForms client, you may want to instead just use the RowChanged event in the DataSet to do your validation, but that does not lend itself to a web environment. I subsequently did a presentation for our CNY Developer Group this month on the contents of this article.
|
 |
|
Comments (0)
|
|
|
|
VS2005 N-Tier Dev Article |
|
Andy's Blog
|
By Andy Beaulieu on
11/11/2005 5:17 PM
|
|
|
|
I have finally posted up an article I wrote on extending the new VS2005 TableAdapters into a multi-tier architecture. It is quite lengthy and shows one way of leveraging the new TableAdapter/DataSet designer in a 3-tier architecture that supports both WinForms and ASP.NET 2.0... Note that if you are creating only a WinForms client, you may want to instead just use the RowChanged event in the DataSet to do your validation, but that does not lend itself to a web environment. I subsequently did a presentation for our CNY Developer Group this month on the contents of this article.
|
 |
|
Comments (2)
|
|
|
|
Julie Lerman visits CNY Developers! |
|
Andy's Blog
|
By Andy Beaulieu on
10/6/2005 5:55 AM
|
|
|
|
Julie Lerman was kind enough to pay our CNY Developer Group a visit last night, and gave her “What's New in ADO.NET 2.0” talk. Great presentation of course, and Julie is obviously one of those speakers who is really into the technology. Julie had so much new stuff to share, I think we could have easily gone for an 8 hour session instead of a couple of hours!
|
 |
|
Comments (0)
|
|
|
|
|
 |
|
 |
|
|