淘先锋技术网

首页 1 2 3 4 5 6 7

 

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