从数据库读取图片,并固定显示

 

None.gif < asp:datagrid id = " DG_Persons "  Width = " 168px "  HeaderStyle - HorizontalAlign = " Center "  Runat = " server "
None.gif                            BorderColor
= " Black "  ItemStyle - BackColor = " Beige "  HeaderStyle - ForeColor = " #ffffff "  HeaderStyle - Font - Bold = " True "
None.gif                            HeaderStyle
- BackColor = " #ff0000 "  AutoGenerateColumns = " False " >
None.gif                            
< ItemStyle BackColor = " Beige " ></ ItemStyle >
None.gif                            
< HeaderStyle Font - Bold = " True "  HorizontalAlign = " Center "  ForeColor = " White "  BackColor = " Red " ></ HeaderStyle >
None.gif                            
< Columns >
None.gif                                
< asp:TemplateColumn HeaderText = " 图片 " >
None.gif                                    
< ItemTemplate >
None.gif                                        
< asp:Image id = Image3 Height = " 186px "  ImageUrl = ' <%# FormatURL(DataBinder.Eval(Container.DataItem, "imgid")) %>' Width="212px" Runat="server">
None.gif
                                         </ asp:Image >
None.gif                                    
</ ItemTemplate >
None.gif                                
</ asp:TemplateColumn >
None.gif                            
</ Columns >
None.gif                        
</ asp:datagrid >

 

ExpandedBlockStart.gif ContractedBlock.gif   Private   Sub BindGrid() Sub BindGrid(ByVal id)
InBlock.gif
InBlock.gif        
Dim strCnn As String = "server=.;database=master1;uid=sa;pwd="
InBlock.gif
InBlock.gif        
Dim myConnection As SqlConnection = New SqlConnection(strCnn)
InBlock.gif        
Dim dst As New DataSet
InBlock.gif        
Dim sda As SqlDataAdapter
InBlock.gif        
'Dim myCommand As SqlCommand = New SqlCommand("SELECT * FROM image1 where imageid=" & i, myConnection)
InBlock.gif
        sda = New SqlDataAdapter("SELECT * FROM KS_img where imgID=" & id, myConnection)
InBlock.gif        
'myCommand.CommandType = CommandType.Text
InBlock.gif
        dst.Clear()
InBlock.gif        sda.Fill(dst, 
"aaa")
InBlock.gif
InBlock.gif        
Try
InBlock.gif
InBlock.gif            myConnection.Open()
InBlock.gif            row 
= table.NewRow
InBlock.gif            
'row.Item("照片") = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
InBlock.gif
            row.Item("imgid"= dst.Tables("aaa").Rows(0).Item(0)
InBlock.gif            row.Item(
"Img"= dst.Tables("aaa").Rows(0).Item(1)
InBlock.gif            
'row.Item("PersonImage") = dst.Tables("aaa").Rows(0).Item(2)
InBlock.gif
            'row.Item("PersonImageType") = dst.Tables("aaa").Rows(0).Item(3)
InBlock.gif
            table.Rows.Add(row)
InBlock.gif            table.GetChanges()
InBlock.gif
InBlock.gif            myConnection.Close()
InBlock.gif            
Me.DG_Persons.DataSource = table
InBlock.gif            
Me.DG_Persons.DataBind()
InBlock.gif
InBlock.gif        
Catch SQLexc As SqlException
InBlock.gif
InBlock.gif            Response.Write(
"Error occured while Generating Data. Error is " & SQLexc.ToString())
InBlock.gif
InBlock.gif        
End Try
InBlock.gif
ExpandedBlockEnd.gif    
End Sub

转载于:https://www.cnblogs.com/fxf568/archive/2006/10/18/532944.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值