下载zip文件后,datalist不是Bind

时间:2013-08-23 05:47:07

标签: asp.net vb.net sql-server-2005 visual-studio-2008

下面是我的按钮搜索代码我需要绑定我的网格并下载zip文件问题是否有zip文件下载但是我的网格没有绑定函数被调用但是datalist没有绑定

Private Sub BindGrid()
    SQL = "Select JameatID,JamaatID,MadrassahID, JameatName,JamaatName,MadrassahName,StudentID,ClassID,DIvisionName,FullName,datediff (year ,DOB,getdate() )as Age  from vwstudent vw LEFT OUTER JOIN CMaster cm ON vw.ClassID =cm.CMID AND MasterName ='ClassID'  where 1=1   order by JameatName,JamaatName,MadrassahName,cm.OrderId "
    Dim ds As New dataset
    ds = gc.GetDataToListBinder(SQL)
    DListPhotoInfo.DataSource = ds 
    DListPhotoInfo.DataBind()

End Sub

Private Sub DownloadImage(ByVal EJID As String)
    Dim DS As Data.DataSet
    Dim tmpZipFile As String
    tmpZipFile = System.IO.Path.GetTempFileName
    Dim zipFile As New GraficaliZip(tmpZipFile)
    zipFile.CreateZipFile()
    Dim strID() As String = Split(EJID.Trim, ",")
    For i As Integer = 0 To strID.Length - 1
         If ImageExist(strID(i).Trim) = True Then
             zipFile.PutFile(Server.MapPath(".") & _
                             "\Photo\" & strID(i).Trim & _
                             ".jpg", strID(i).Trim & ".jpg")
         End If
     Next
       BindGrid() ///from here i am binding grid
     zipFile.SaveFile()
     gc.DownLoadFileFromServer("", tmpZipFile & ".zip", "Photo.zip")
End Sub

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click


    DownloadImage("20312059,20313178")
    PnlGrid.Visible = True
End Sub

1 个答案:

答案 0 :(得分:1)

在pageLoad事件中调用你的BindGrid()方法!IsPostBack

有关

Page_load()
{
 if(!IsPostBack)
 {
 BindGrid()
 }    
}

并且您还需要在下载按钮单击事件中调用BindGrid()方法

Private Sub DownloadImage(ByVal EJID As String)
    Dim DS As Data.DataSet
    Dim tmpZipFile As String
    tmpZipFile = System.IO.Path.GetTempFileName
    Dim zipFile As New GraficaliZip(tmpZipFile)
    zipFile.CreateZipFile()
    Dim strID() As String = Split(EJID.Trim, ",")
    For i As Integer = 0 To strID.Length - 1
         If ImageExist(strID(i).Trim) = True Then
             zipFile.PutFile(Server.MapPath(".") & _
                             "\Photo\" & strID(i).Trim & _
                             ".jpg", strID(i).Trim & ".jpg")
         End If
     Next
     zipFile.SaveFile()
     gc.DownLoadFileFromServer("", tmpZipFile & ".zip", "Photo.zip")
 **BindGrid()**
End Sub

<强>更新

首先调用下载方法,然后点击搜索按钮时调用绑定方法

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click


    DownloadImage("20312059,20313178")
 **BindGrid()**
    PnlGrid.Visible = True
End Sub

修改: 如果您使用了更新面板,那么

致电UpdatePanelID.Update()()

后致电BindGrid
  • UpdatePanel控件嵌套在另一个UpdatePanel控件中并更新父面板时。

更多问题:

查看此链接的

http://forums.asp.net/t/1605207.aspx

Update Datalist in UpdatePanel

http://forums.asp.net/t/1320236.aspx/1?update+panel+doesnot+refresh+the+datalist+control+for+first+time