KavyaVS
asked on
How to save the DataTable for furhter access with .Net generics
Hi,
Instead of accesing the database multiple times,I am storing the DataTable in ViewState.
DataTable dtSql = (DataTable) ViewState["tblxmlcol"];
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState and accessing the Xml contents column and decoding it to Html.
It is slowing down the process.Is there any way can I make it faster.
Instead of storing the DataTable in ViewState and converting it to DataTable again can you suggest something using.Net generics or something else.
Thanks,
Instead of accesing the database multiple times,I am storing the DataTable in ViewState.
DataTable dtSql = (DataTable) ViewState["tblxmlcol"];
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState and accessing the Xml contents column and decoding it to Html.
It is slowing down the process.Is there any way can I make it faster.
Instead of storing the DataTable in ViewState and converting it to DataTable again can you suggest something using.Net generics or something else.
Thanks,
Put a sample code here which can reflect your issue for us , so we can suggest any ideas to improve .
Meeran03
Meeran03
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am binding the DataTable column to left menu link.
I am stroing the DataTable in ViewState in the Page's original request.
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState.
Instead of accessing the DataBase multiple times,whenever the link from left menu is clicked
I am getting the dataTable back from ViewState.
I have 20 links in left menu.Instead of storing the DataTable in ViewState and converting it to DataTable again can you suggest something.
Thanks
I am stroing the DataTable in ViewState in the Page's original request.
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState.
Instead of accessing the DataBase multiple times,whenever the link from left menu is clicked
I am getting the dataTable back from ViewState.
I have 20 links in left menu.Instead of storing the DataTable in ViewState and converting it to DataTable again can you suggest something.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Rouchie,
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState and accessing the Xml contents column and decoding it to Html and showing it in webpage.
Everytime when the link is clicked I am not accessing the DataBase.I am getting the DataTable back from ViewState.I am looking for something more efficient than this.
Protected Sub lnk_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim s As LinkButton = CType(sender, LinkButton)
Dim sID As String = s.ID.ToString()
Dim sAdDetails As String = String.Empty
Dim dtAd As New DataTable
dtAd = CType(ViewState("AdDetails Table"), DataTable)
Dim drFilteredRow As DataRow() = dtAd.Select("Ad_Code = " & Convert.ToInt16(sID.ToStri ng()))
For Each dr As DataRow In drFilteredRow
sAdDetails = dr("Ad_Detail").ToString()
Next
sAdDetails = Server.HtmlDecode(sAdDetai ls.Replace ("<AdConte nts>", "").Replace("</AdContents> ", ""))
vgAdDetails.InnerHtml = sAdDetails
Catch ex As Exception
End Sub
Thanks
On web page left menu links,when the link is clicked I am getting DataTable back from ViewState and accessing the Xml contents column and decoding it to Html and showing it in webpage.
Everytime when the link is clicked I am not accessing the DataBase.I am getting the DataTable back from ViewState.I am looking for something more efficient than this.
Protected Sub lnk_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim s As LinkButton = CType(sender, LinkButton)
Dim sID As String = s.ID.ToString()
Dim sAdDetails As String = String.Empty
Dim dtAd As New DataTable
dtAd = CType(ViewState("AdDetails
Dim drFilteredRow As DataRow() = dtAd.Select("Ad_Code = " & Convert.ToInt16(sID.ToStri
For Each dr As DataRow In drFilteredRow
sAdDetails = dr("Ad_Detail").ToString()
Next
sAdDetails = Server.HtmlDecode(sAdDetai
vgAdDetails.InnerHtml = sAdDetails
Catch ex As Exception
End Sub
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Rouchie,
If I am hitting the Database eachtime for each link it is taking time to load the advertisement.It is an internet application and lot of users means it definitely slows down the server.
The XML content doesn't change.I tried both Session and ViewState for storing the DataTable.But they are still slow.
You mentioned Cache allows the same memory to be accessed by everyone, so they all see the same data. Useful for sharing.
How to store the DataTable in cache.
Thanks.
If I am hitting the Database eachtime for each link it is taking time to load the advertisement.It is an internet application and lot of users means it definitely slows down the server.
The XML content doesn't change.I tried both Session and ViewState for storing the DataTable.But they are still slow.
You mentioned Cache allows the same memory to be accessed by everyone, so they all see the same data. Useful for sharing.
How to store the DataTable in cache.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
There is no replacement to storing the datatable in ViewState. You have to hit the database if you want to reduce the pagesize.