Develop download system with ASP, NET

zhaozj2021-02-17  45

Develop download system with ASP, NET

Front interface part

Main interface

The main interface is a TreeView control to add classification information.

The main interface is that the lower left part is a list control to display the download information list.

The main interface is the right part is a DataGrid control to display download information.

This is a basic interface. If you need more features, please expand your own!

Steps: Create a new project (select the ASP.NET application), add a web reference, renamed to Downws

Add a DataGrid on the form, set its properties with the property generator: column, pagination, format, etc., then set the data source for the DataGrid in the code, then bind, rendering the above style.

Add TreeView, List and other controls. Add data to TreeView in the program, please see below:

Note:

Internet Explorer WebControls not standard VS.NET Server Control, the site is downloaded to Microsoft: http:? //Msdn.microsoft.com/downloads/samples/internet/default.asp url = / Downloads / samples / Internet / ASP_DOT_NET_ServerControls / WebControls / default.asp Download the first time after installation, right-click the toolbox Customize Toolbox ... → .NET Framework Components to find microsoft.web.ui.webcontrols.treeview, this TreeView control appears in the toolbox .

DownInfo.aspx.vb:

Imports system.configuration

Imports system.data

Imports system.data.sqlclient

Imports Microsoft.Web.ui.WebControls

Public Class DownInfo

Inherits System.Web.ui.page

Protected withevents datagrid1 as system.Web.ui.WebControls.DataGrid

Protected Withevents TreeView1 as Microsoft.Web.ui.WebControls.treeView

Protected Withevents Label2 As System.Web.ui.WebControls.Label

Protected Withevents label3 as system.web.ui.webcontrols.label

Protected Withevents ListBox1 As System.Web.ui.WebControls.listbox

Protected Withevents Form1 As System.Web.ui.htmlControls.htmlform

#Region "The code" of the web form designer "

'This call is required for the web form designer.

private subinitializecomponent ()

End Sub

Private sub page_init (byval sender as system.object, byval e as system.eventargs) Handles mybase.init

'Codegen: This method call is necessary for the web form designer

'Don't modify it using the code editor.

InitializationComponent () End Sub

#End region

DIM DOWNDV As New DataView ()

DIM STRNAME AS STRING

Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load

'

Strname = Request.QueryString ("strname")

'Instantiate a DownWebService

DIM WS as new downws.downwebservice ()

DIM DSTREE AS ​​Dataset

'Get all categories

DSTREE = ws.getdownloadclass

'Pack in the tree structure

TreeView1.nodes.clear ()

DIM ROW AS DATAROW

For each row in dstree.tables (0) .rows

Dim item as new treenode ()

Item.text = row.item ("classname"). Tostring

'When you click on the URL to jump

item.navigateURL = "Downinfo.aspx? Strname =" & rotion.Item ("classname"). Tostring

'Picture of each branch

item.imageurl = resolveurl (me.templatesourcedirectory & "/tree.jpg")

TreeView1.nodes.Add (item)

NEXT

'Get all download information, after the classification is filtered, fill it to DataGrid

Downdv = ws.getdownfo (). Tables (0) .defaultView

IF strname <> "" ""

Downdv.rowfilter = "classname = '" & strname & "'"

END IF

DataGrid1.datasource = Downdv

DataGrid1.databind ()

End Sub

Private sub DataGrid1_Selected Indexchanged (Byval e as system.EventArgs) Handles DataGrid1.Selected IndexChanged

'Get the current ID

DIM NID AS INT32 = DataGrid1.SelectedItem.cells (0) .Text

'Get URL

DIM STRURL AS STRING = "Downdetail.aspx? Id =" nid.toString ()

'Open a window, no toolbar, status bar

Response.write ("