2

Below is my code on button search i need to bind my grid and download zip file problem is there zip file is download but my grid is not bind function is called but datalist is not bind

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
Harsh
  • 165
  • 2
  • 2
  • 10
  • Can you also include the code for your `BindGrid()` function? – Adrian Aug 23 '13 at 05:51
  • i update my code for bindgrid plz refer – Harsh Aug 23 '13 at 05:54
  • May be some other code is spoiling the DataList. So... Try putting breakpoint @ the last line of `BindGrid()` method. Confirm the data fetched and bind properly to the DataList. Then move forward step by step to check which part of the code is disturbing the DataList after it has been bind properly. – Khadim Ali Aug 23 '13 at 06:44

1 Answers1

1

Call your BindGrid() method inside of !IsPostBack in pageLoad event

For

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

and also you need to call your BindGrid() method in download button click event

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

Update:

first call download method ,then call binding method when your search button on-click

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

Edit : If you used update panel , then

Call UpdatePanelID.Update() after call BindGrid()

  • When the UpdatePanel control is nested inside another UpdatePanel control and the parent panel is updated.

More problems :

Look this link's

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

Community
  • 1
  • 1
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234