----------------------------------------------------------------------------------------------------------------------------------------
GridView 數字欄位加千分號
<asp:Label ID="lb_text" runat="server" Text='<%# Eval("CONSOLIDATED_REVENUE","{0:N0}") %>'></asp:Label>
or
<asp:BoundField DataField="CONSOLIDATED_REVENUE" HeaderText="合併營收" DataFormatString="{0:N0}"
SortExpression="CONSOLIDATED_REVENUE" ItemStyle-HorizontalAlign="Center" >
</asp:BoundField>
----------------------------------------------------------------------------------------------------------------------------------------
GridView & DataList --DataBind取值方法
##############
http://scenic0327-tek.blogspot.tw/2012/03/blog-post_29.html
##############
http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD20110730191358HNV.html
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lnkView As New LinkButton()
lnkView.ID = "patent_id"
lnkView.Text = TryCast(e.Row.DataItem, DataRowView).Row("patent_id").ToString()
AddHandler lnkView.Click, AddressOf ViewDetails
lnkView.CommandArgument = TryCast(e.Row.DataItem, DataRowView).Row("patent_id").ToString()
e.Row.Cells(1).Controls.Add(lnkView)
'For i As Integer = 0 To e.Row.Cells.Count - 1 'row的值
' xxx.Text += e.Row.Cells(i).Text & "<br/>"
' 'If e.Row.Cells(i).ClientID = "img" Then
' ' xxx.Text = "Y"
' 'End If
'Next
For i As Integer = 0 To GridView1.HeaderRow.Cells.Count - 1 '標題的值
If GridView1.HeaderRow.Cells(i).Text = "簡圖" Then
If TryCast(e.Row.DataItem, DataRowView).Row("img").ToString() <> "" Then
Dim img As New Image()
img.ID = "img"
img.Width = 100
img.ImageUrl = "FileStagingPath/" & TryCast(e.Row.DataItem, DataRowView).Row("img").ToString()
e.Row.Cells(i).Controls.Add(img)
End If
End If
Next
'Dim txtCountry As New TextBox()
'txtCountry.ID = "name"
'txtCountry.Text = TryCast(e.Row.DataItem, DataRowView).Row("name").ToString()
'e.Row.Cells(2).Controls.Add(txtCountry)
End If
##############
Imports System.IO
'判斷FileUpload檔案是否存在
If (FileUpload_Img.HasFile) Then
End If
'取得上傳檔案的集合
Dim hfc As HttpFileCollection = Request.Files
For j As Integer = 0 To hfc.Count - 1
Dim fileName As String = Mid(hfc(j).FileName, InStrRev(hfc(j).FileName, "\") + 1, Len(hfc(j).FileName)) '檔案名稱(含副檔名)
Dim fileNameEx As String = Mid(hfc(j).FileName, InStrRev(hfc(j).FileName, "."), Len(hfc(j).FileName)) '副檔名
Dim fileSize As String = hfc(j).ContentLength '檔案大小
Next
'判斷上船的目錄路徑是否存在
If My.Computer.FileSystem.DirectoryExists(saveDir1) Then
End If
'建立目錄路徑
My.Computer.FileSystem.CreateDirectory(saveDir1)
'判斷目錄是否有相同檔案名稱
If File.Exists(filePath) Then
End if
'變更檔案名稱
File.Move("ttt.txt", "ttt-1.txt")
https://msdn.microsoft.com/zh-tw/library/cc148994.aspx
#####################
資料繫結
<%# DataBinder.Eval(Container, "DataItem.description")%>
######################
DataList
DataList刪除
<asp:ImageButton ID="imgBut_delete" runat="server" ImageUrl="images/CNSREJ16.GIF" CommandName="delete" />
要加入DataKeyField
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" DataKeyField="detailed_id" >
Protected Sub DataList1_DeleteCommand(source As Object, e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.DeleteCommand
Dim keyID As Integer = Convert.ToInt32(DataList1.DataKeys(e.Item.ItemIndex))
End Sub
DataList 資料內容處理
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'處理子層DataList2的資料
Dim dl2 As DataList = CType(e.Item.FindControl("DataList2"), DataList)
'Dim hidden2 As HiddenField = DirectCast(e.Item.FindControl("lb_needDate"), HiddenField)
'Dim QID As String = hidden2.Value
'If QID = 33 Then
For Each li As DataListItem In dl2.Items
Dim lbl As Label = DirectCast(e.Item.FindControl("lb_needDate"), Label)
If lbl IsNot Nothing Then
If lbl.Text = "Self Directed" Or lbl.Text = "Systems" Then
lbl.Visible = False
End If
End If
Next
'End If
End If
End Sub
#####
檔案上傳
多個檔案上傳
沒有留言:
張貼留言