2

下面是我在按钮搜索上的代码我需要绑定我的网格并下载 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
4

1 回答 1

1

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

为了

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

在 UpdatePanel 中更新 Datalist

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

于 2013-08-23T05:59:59.043 回答