当前位置:  编程技术>.net/c#/asp.net
本页文章导读:
    ▪获取GridView行索引      Insus.NET为了演示这个例子,首先准好数据,创建一个类别Imports Microsoft.VisualBasicNamespace Insus.NET Public Class Cosmetic Private _ID As Integer Private _Type As String Private _Name As String Priv.........
    ▪点滴积累---ASP.NET TreeView读取数据库       1 前台: 2 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TreeView._Default" %> 3 4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitio.........
    ▪点滴积累---委托编号大排行(自动生成)       委托编号大排行(自动生成):效果:描述:在本表中自动生成编号,自动生成的编号为所有表中的排序。例如:在添加页面中生成的委托编号未00048,那么在别的表中生成的编号为00049。.........

[1]获取GridView行索引
    来源:    发布时间: 2013-10-28

Insus.NET为了演示这个例子,首先准好数据,创建一个类别

Imports Microsoft.VisualBasic

Namespace Insus.NET
Public Class Cosmetic
Private _ID As Integer
Private _Type As String
Private _Name As String
Private _Weight As Decimal
Private _UM As String

Public Property ID As Integer
Get
Return _ID
End Get
Set(value As Integer)
_ID = value
End Set
End Property

Public Property Type As String
Get
Return _Type
End Get
Set(value As String)
_Type = value
End Set
End Property

Public Property Name As String
Get
Return _Name
End Get
Set(value As String)
_Name = value
End Set
End Property

Public Property Weight As Decimal
Get
Return _Weight
End Get
Set(value As Decimal)
_Weight = value
End Set
End Property
Public Property UM As String
Get
Return _UM
End Get
Set(value As String)
_UM = value
End Set
End Property

Public Sub New()

End Sub

Public Sub New(id As Integer, type As String, name As String, weight As Decimal, um As String)
Me._ID = id
Me._Type = type
Me._Name = name
Me._Weight = weight
Me._UM = um
End Sub
End Class
End Namespace

 
上面创建好的只是一对象,得需用数据填充,让它有血有肉有灵魂。

Private Function GetData() As List(Of Cosmetic)
Dim o As New List(Of Cosmetic)
Dim c As New Cosmetic(1, "滋润霜", "玉兰油", 50, "g")
o.Add(c)

Dim c1 As New Cosmetic(2, "滋润霜", "雅诗兰黛", 100, "g")
o.Add(c1)

Dim c2 As New Cosmetic(3, "滋润霜", " 兰蔻", 80, "
    
[2]点滴积累---ASP.NET TreeView读取数据库
    来源:    发布时间: 2013-10-28
1 前台:
2 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TreeView._Default" %>
3
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" >
7 <head runat="server">
8 <title></title>
9 </head>
10 <body>
11 <form id="form1" runat="server">
12 <div>
13 <asp:TreeView ID="TreeView1" runat="server" ShowLines="True">
14 </asp:TreeView>
15 </div>
16 </form>
17 </body>
18 </html>
19
20
21
22 后台:
23 using System;
24 using System.Collections.Generic;
25 using System.Linq;
26 using System.Web;
27 using System.Web.UI;
28 using System.Web.UI.WebControls;
29 using System.Data;
30 using System.Data.SqlClient;
31 using System.Configuration;
32
33 namespace TreeView
34 {
35 public partial class _Default : System.Web.UI.Page
36 {
37 public static string st = ConfigurationManager.ConnectionStrings["sql"].ToString();
38 private DataTable dts=new DataTable();
39 protected void Page_Load(object sender, EventArgs e)
40 {
41 if (!IsPostBack)
42 {
43 dts = CreateTable();
44 CreateNode();
45 }
46 }
47 public void CreateNode()
48 {
49 DataRow[] dr = dts.Select("ParentID=0");
50 if(dr.Length>0)
51 {
52 foreach(DataRow drr in dr)
53 {
54 TreeNode tn = new TreeNode();
55 tn.Value = drr["MenuID"].ToString();
56 tn.Text = drr["MenuName"].ToString();
57 tn.Expanded = false;
58 tn.SelectAction = TreeNodeSelectAction.Expand;
59 TreeView1.Nodes.Add(tn);
60 CreateChild(tn,dts);
61 }
62 }
63 else
64 {
65 TreeNode t=new TreeNode();
66 t.Value="空";
67 t.Text="空
    
[3]点滴积累---委托编号大排行(自动生成)
    来源:    发布时间: 2013-10-28

 

委托编号大排行(自动生成):

效果:

描述:在本表中自动生成编号,自动生成的编号为所有表中的排序。例如:在添加页面中生成的委托编号未00048,那么在别的表中生成的编号为00049。

调用:

1 protected void Page_Load(object sender, EventArgs e)
2 {
3 Response.Expires = -1;
4 if (!IsPostBack)
5 {
6
7 if (ActionType == CommonEnum.ActionLevel.Write)
8 {
9
10 tbwtbh.Text = Getwtbh();
11
12 }
13 }
14 }
15
16 protected string Getwtbh()
17 {
18 string Getwtbh = CommonFunction.GetByMenuCode(ThisPositionID, ApplicationInfo.SerialNumWt, "qjlzhuan_lydj", "wtbh");
19 return Getwtbh;
20 }

函数:

1 #region 委托编号大排行
2
3 public static string GetByMenuCode(string ThisPositionID, int Digit, string TableName, string RowName)
4 {
5 string GetCode = string.Empty;
6 string Title = string.Empty;
7 string sql = string.Format(@"SELECT Max(RIGHT({0}," + Digit + ")) as RowName FROM {1}; " +
8 "SELECT LEFT(Max({2}),LEN(Max({2}))-" + Digit + ") as RowTitle FROM {3}", "wtbhCode", "wtbh", RowName, TableName);
9 DbCommand sqlCommand = ERPDataBase.ERPDB.GetSqlStringCommand(sql);
10 DataSet dsData = new DataSet();
11 ERPDataBase.ERPDB.LoadDataSet(sqlCommand, dsData, new string[] { "data", "Title" });
12 if (dsData.Tables["data"].Rows.Count > 0)
13 {
14 DataRow row = dsData.Tables["data"].Rows[0];
15 if (row["RowName"] == DBNull.Value)
16 {
17 GetCode = "1";
18 GetCode = GetCode.PadLeft(Digit, '0');
19 }
20 else
21 {
22 string second = row["RowName"].ToString();
23 GetCode = second.PadLeft(Digit, '0');
24 }
25 }
26 if (dsData.Tables["Title"].Rows.Count > 0)
27 {
28 DataRow row = dsData.Tables["Title"].Rows[0];
29 if (row["RowTitle"] != DBNull.Value)
30 {
31 Title = row["
    
最新技术文章:
 




特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3