2013-08-23 97 views
2

下面是我的代碼按鈕搜索我需要綁定我的網格和下載zip文件的問題有沒有zip文件是下載但我的網格是不綁定功能被稱爲但datalist不綁定後下載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 
+0

你能還包括你的'BindGrid()'functi代碼上? – Adrian

+0

我更新我的代碼bindgrid PLZ參考 – Harsh

+0

可能是一些其他代碼破壞DataList。所以... 嘗試把斷點@ BindGrid()方法的最後一行。確認獲取的數據並正確綁定到DataList。然後逐步前進,以檢查哪些代碼在正確綁定後會干擾DataList。 –

回答

1

打電話給你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 

編輯: 如果使用更新面板,然後

致電呼叫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

+0

謝謝,但我的bindgrid已經在發回虛假 – Harsh

+0

請再一次看到我的答案。 –

+0

好吧,先生,我會檢查 – Harsh