Requirements |
|
RadControls version | RadControls for ASP.NET AJAX 2010.1 519 |
.NET version | 2.x |
Visual Studio version | 2005/8 |
programming language | VB.NET |
browser support |
all browsers supported by RadControls |
PROJECT DESCRIPTION
I am storing different versions of an Excel file in a SQL Server table. Each row in the file is a row in the table. Different versions are differentiated by a VersionNumber column. This code allows the user to view different versions of the file in a RadGrid. Steps:
First you will need a table defined that includes a column for the version. You will need a way to increment the version as you insert new rows to the table. I use stored procedures to insert and select from the tables.
Then:
1. Have a radgrid defined to hold the data
2. Create a drop down and link buttons to select either a given version or the current version
<asp:DropDownList ID="ddlVersion" runat="server" Width="250px"> |
</asp:DropDownList> |
<asp:LinkButton ID="lbViewVersion" Text="View selected Version" runat="server"> |
</asp:LinkButton> |
<br /> |
<asp:LinkButton ID="lbViewCurrentVer" Text="View current Version" runat="server"> |
</asp:LinkButton> |
3. Create a method to pull the data based on the ddl and link button selections
Protected Sub GetInventoryData(ByVal displayType As String) |
' set your data access here |
' ... |
Dim inventoryData As DataSet |
Try |
' If different version is selected get the version from the drop down and pass it into a stored procedure |
If displayType = "diffVersion" Then |
Dim inParams As New NameValueCollection |
Dim version As Int16 |
version = ddlVersion.SelectedValue |
With inParams |
.Add("@versionNum", version) |
End With |
inventoryData = <your data call to the stored procedure, passing in the version as input param> |
Else |
' I go to a different table and procedure if it's current version so I need an else without input params |
inventoryData = <your data call to the stored procedure> |
End If |
rgridInventory.DataSource = inventoryData |
rgridInventory.DataBind() |
Catch ex As Exception |
' your error catching protocol |
Finally |
End Try |
End Sub |
4. Call the method -- passing in whether you want the current or earlier version. The example below gets a different version
' pulls in different version |
GetInventoryData("diffVersion") |