Blog Stats
  • Posts - 4
  • Articles - 0
  • Comments - 6
  • Trackbacks - 4

 

Empty Dataset

I was toying around today with controls from Dart Communciations. Their controls have built in callback technology. That means you don’t have to write one line of code on the client-side for ASP.Net. Anyway…

I have these panels that are hidden on my page. When you select a menu button, the panel that corresponds to the button selected is displayed and the data is updated. The problem I was having was – some of the panels have grids on them. At the time the page is rendered there is no data for the grids. So, when the page was “refreshed” the grids didn’t show the new data.

This happens because a callback will only update items that have been rendered previously. Since the grids didn’t have data in them, they were never rendered. So, I put this little chunk of code in the page_load event and it solved the issue. Essentially I’m creating a pseudo-empty dataset. I hope others will find use for this, too.

SQL = "Declare @str as varchar(1) "
SQL &= "Select @str = '' Select @str"
DataSet = GetDataSet(SQL, cs, "Empty")
grdToShow.DataSource = DataSet
grdToShow.DataBind()

Here’s the GetDataSet function just incase you want to use it, too.

Private Function GetDataSet(ByVal SelectString As String, ByVal ConnectionString As String, ByVal TableName As String) As DataSet
   Dim DataSet As DataSet
   DataSet = New DataSet
   da = New SqlDataAdapter(SelectString, ConnectionString)
   da.Fill(DataSet, TableName)
   Return DataSet
End Function


TTFN,

Mark

Feedback

No comments posted yet.


Post a comment





 

 

 

Copyright © Mark Pritchard