Asp.Net 网页开发

1. 对ispostback的理解:
   public   void   Page_Load(Object   src, EventArgs   e)  
          Me.LoadData()  //页面第一次加载时要执行的事件,当不是第一次加载时不执行此事件  
2. 显示数据:
Private Sub LoadData()
        Dim objCs As New CS             //辅助类,其中自己写函数
        Dim objDs As New DataSet
        Dim objDv As DataView
        objDs = objCs.GetPrice          //调用方法读取数据,存入objDs
        If objDs.Tables.Count > 0 AndAlso objDs.Tables(0).Rows.Count > 0 Then
            objDv = objDs.Tables(0).DefaultView
            objDv.Sort = ViewState("sort")
            With Me.dgPrices              //DataGrid
                .Visible = True
                .DataSource = objDv
                .DataBind()                  //绑定数据
            End With
            If Me.dgPrices.PageCount > 1 Then
                Me.dgPrices.PageStyle.Visible = True    //大于一页时,显示页码
                Me.dgPrices.PageStyle.Visible = False
            End If
            Me.dgPrices.Visible = False    //未收到数据,不显示
        End If
Public Function GetPrice() As DataSet
        Me.SelectCommand = Nothing
        With Me.SelectCommand
            .CommandType = CommandType.StoredProcedure
            .CommandText = "price_get"      //存储过程
        End With
        Return Me.QueryData("GetPrice")    //执行了连接操作并返回dataset型数据
    End Function
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s