Persisting Datable On Post Backs

Mar 16, 2015

I am retrieving results from a SQL database based on a user file upload, and I am saving the returned results in a datatable. It can be up to 15,000 rows. I need to use this datatable in other requests in this same page - i.e. saving the data back to another table, exporting to a file....How can I store the datatable to access again? I read up on viewstate, session , and cache, but they all seem to have an affect on performance and memory.

View 7 Replies


Similar Messages:

Web Forms :: DoPostBack Does Not Occur Post Backs?

Dec 9, 2010

Here is my simple markup, I hope its understandable as to what I am trying to do

<form id="form1" runat="server">

View 10 Replies

.net - Possible To Keep File Path Across Post Backs With The FileUpload Control?

Feb 12, 2011

I have a situation where I want a user to select a file, then select an option from a DropDownList. When they select an item from the DropDownList I do an auto post back and do some stuff with the file, but this causes the path to clear out. Is there some way that I can keep the path from clearing out?

View 2 Replies

MVC :: Retain Partial Data In Model Over The Post Backs?

Oct 12, 2010

I have recently started learning ASP.NET with MVC 2 Framework, I am facing difficulties in the following scenarios.In my MVC application I want to retain partial information in Model over post backs.Following is my scenario,

1. I initiate "Edit" of main record by clicking date hyperlink from left navigation.

2. Amend some data.

3. Save the record.

4. "Edit" sub record of the saved record by clicking another hyperlink from bottom left navigation panel.

The page is divided in to 6 tabs, the first 5 tabs shows the data for the main record and the 6th tab shows data of sub record. Wehn we "Edit@ sub record the previous 5 tabs doesn't have any changes noted, that means there is no harm in keeping their details intact in the main model. So is there a way to access model in the controller on hyper link click action so that I can only load the data for the clicked sub record (I am asking this, because the hyperlink click uses HTTP GET method so no model parameter passed in action method). If no, then how do I retain partial values in the Model over post backs?

Note that each tab data have been kept in individual models, and a main model has a collection member to hold all these individual models together.I thought as the model is binded with the view, it is too binded with controller. But it is allowing easily to access model in variable "Model" for the view but not for the controller.

View 3 Replies

SQL Reporting :: Reportviewer Sorting Fails In Successive Post Backs?

Jan 19, 2010

I have created a rdlc file (Binded its columns accordingly, sorting is enabled on few columns) and rendering it using a reportviewer control. Everything works fine while loading report first time; it shows the progress indicator & loads it correctly. When I click on sort_button(default shown by control itself) it sorts correctly. Now successive clicks on sort_button shows error :

An error occurred during local report processing. An internal error occurred on the report server. See the error log for more details. Gone through the log at server:

Program FilesMicrosoft SQL ServerMSSQL.3Reporting ServicesLogFilesReportServerService__01_19_2010_01_34_05.log but not able to deduce any fruitful exception.

Trace value in config file is set to :< add value="3" />

Either disable the sort_button till the report loads completely. Or show the progressbar indicator till the report loads completely.I am not able to find out the solution for: how to achieve any of the two ways mentioned above.

View 2 Replies

Web Forms :: Count No Of Site Hits Excluding Post Backs?

Nov 24, 2010

How to count no of site hits of a site with out using postbacks i.e we should not count

no of postbacks of a page only single hit should be taken in to account..

View 3 Replies

Web Forms :: Load The Dynamically Added HTML Controls During The Post Backs Without Loosing Their States?

Mar 5, 2010

Can any one let me know "How to load the dynamcially added HTML Controls(Controls added using javascript) during the postbacks without loosing their values?

View 1 Replies

How To Convert Datable To Html Table

Jan 7, 2011

for my web part,i need to show some data of data table.now,i m developing in asp.net with c#.how i convert to html table from data table?And also,i don't need to show some columnsuch as ItemID.my data table will be like this.

ItemID ItemName Qty Price Unit Amount

I-0001 ItemOne 10 100 Box 1000
I-0002 ItemTwo 20 200 Card 4000
I-0003 ItemThree 30 300 Tab 9000

itemID column is not need to show.i want only itemname,qty,price,unit,amount columns.
please give me right way.

View 2 Replies

ADO.NET :: Assign Datable Column Bit Value To Bool Or Check Box?

Jan 24, 2011

I have a DataTable, one of the column data type is of type Bool or sql(Bit).

now i want to assign this value to a Bool variable/object or lets say i want to assign this to a checkbox, How do i do that

eg. not correct though

DataTable dt= new DataTable();
Bool a= dt.Rows[0]["IsApproved"];
cb.Checked=dt.Rows[0]["IsApproved"];

View 2 Replies

Forms Data Controls :: Cant Get New Value From Gridview With Datable Datasource

Dec 16, 2010

I have read many, many articles about this issue and still cannot fix my gridview. It is a simple datagrid with a couple readonly fields and then one field is available for edit. I cannot get the new value the user enters into the grid for update... My grid can delete and cancel. I am dynamically binding and know that I have to handle this but I cannot get teh changed quanitity value out of the grid.

This is what is failing...

'The value that changed is blank but I can see the read only values here!!
hfQuantity.Value = gvCart.Rows(e.RowIndex).Cells(2).Text.ToString()

Here is my gridview:

<asp:GridView
ID="gvCart"
runat="server"
AutoGenerateColumns="False"
EnableTheming="False"
GridLines="None"
DataKeyNames="PRDID">
<Columns>
<asp:BoundField
HeaderText="Vendor Number"
DataField="VNDNO"
ReadOnly="True">
</asp:BoundField
<asp:BoundField
HeaderText="Product ID"
DataField="PRDID"
ReadOnly="True"
HeaderStyle-Width="90px"
ItemStyle-Width="90px">
</asp:BoundField>
<asp:BoundField
HeaderText="QUANTITY"
DataField="QUANTITY"> </asp:BoundField>
<asp:CommandField
ShowEditButton="True"
HeaderStyle-Width="60px"
ItemStyle-Width="60px"
CausesValidation="false">
</asp:CommandField>
</Columns>
</asp:GridView>

Code behind:

Private Sub gvCart_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvCart.RowEditing
gvCart.EditIndex = e.NewEditIndex
gvCart.DataSource = Session("CartTable")
gvCart.DataBind()
End Sub
Private Sub gvCart_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvCart.RowUpdating
'Find the row that was clicked for updating.
Dim row As GridViewRow = gvCart.Rows(e.RowIndex)
'Change the edit index to -1
gvCart.EditIndex = -1
If row IsNot Nothing Then
'The value that changed is blank but I can see the read only values here!!
hfQuantity.Value = gvCart.Rows(e.RowIndex).Cells(2).Text.ToString()
Dim myDatatable As New DataTable
'Find the Control in the grid.
myDatatable = Session("cartTable")
For i As Integer = 0 To myDatatable.Rows.Count - 1
If e.RowIndex = i Then
myDatatable.Rows(i)(2) = hfQuantity.Value
Session("cartTable") = myDatatable
gvCart.DataSource = Session("CartTable")
gvCart.DataBind()
End If
Next
End If
End Sub

View 2 Replies

NHibernate Not Persisting Owned Objects?

Jul 30, 2010

I have just gotten a very odd error and I can't explain, or trace it out. My forum entity maintains a list of child forums. The list is internal, and exposed as an ienumerable, along with some methods like AddChild, FindChild and RemoveChild. Now to the code:

[Code]....

I have stepped through this several times, testing values along the way. It works perfectly, so I cannot explain the error. If a parent forum id is given, forumRepository.Update(parent) runs with no errors, it just doesn't actually save the new child to the db.

Incidentally... until I restart VS2010, the nhibernate session actually THINKS it HAS worked, and the new record shows on the page.

View 3 Replies

MVC :: Persisting Model State Across Requests?

Jan 3, 2011

I'm building a web application that has a particular model representing some events. Users need to be able to add N number of people to a given event. Choosing people is handled by a partial view.

I'm trying to build a menu that displays when users click "add a person" to the event. Because the event hasn't been filled out completely yet, there is nothing in the database to persist between requests.

I also have validation logic on the event page.

My proposed solution is to add the form to search or add for people on the event form itself and have a submit button that sends the values that have been added back to the server, where I can store them in ViewData or Session.

Unfortunately, doing this flags the validation.

My second solution is to load a partial view responsible for loading the UI to add/search for a person. I could add a little code on the method in the controller that returns a partial view storing the existing data in a session variable or viewdata. Trouble is, I have to submit the form to do it--again tripping the validation!!!

I'm wondering if perhaps I chose the wrong tool to do this...because in webforms, there would probably be a postback and you would just perform an operation on that postback. I'd like to avoid rewriting the application in webforms and am wondering if there are ways I'm overlooking in ASP.NET MVC.

View 2 Replies

Persisting GridView Data Across PostBacks?

Apr 4, 2011

Alright, so here's my basic ASP.NET page setup: I've got a page with a GridView that has ContentTemplates in it. You can add a row and edit/remove rows at any time. There's a "New" button that creates a new row.

All of this data is bound to custom data objects. So if I have a GridView of "People" and each row has "FirstName", "LastName", and "Gender" (with TextBox and DropDown controls), I then have a "Person" object which has public properties for "FirstName", "LastName", etc. I have the binding set up correctly, and I can push data into the GridView from the object, and I persist the object with the Session variable. My page lifetime structure looks something like this:

Page_Load: Loads the List(Of Person) from Session()

Any events fire, and modify the List(Of Person).After any event, the List(Of Person) gets saved back into Session(), and is then DataBound to the GridView (and any subsequent fields are also DataBound, such as the DropDownList.

My question is: Whenever I fill in rows in the GridView, and then add a new row (there is no database saving going on whatsoever), my fields clear out and don't persist across PostBacks. So, how can I persist my custom data objects with databinding across postbacks?

View 2 Replies

C# - Persisting Dynamic Controls Over Postback?

Sep 30, 2010

I have a datagrid that loads on page_load.

In this instance I can't load the datagrid in page_init as the results of the datagrid are determined by a checkbox and the checkbox would always be set to true during page_init to the viewstate not being loaded.

I have an OnItemDataBound event on the datagrid that dynamically creates controls and later on I want to access the value of some of these controls (e.g. a text box)

Of course the problem is I can't access these controls values as they don't persist over a postback.

View 1 Replies

MVC :: Persisting The Country For The Logged On User?

Jun 22, 2010

I am new to ASP.NET MVC and I am using ASP.NET MVC 2. I am trying to implement the following feature and I need your expertise on this:

Authentication is Windows Authentication. Every user has at least one country associated to his/her account that he needs to manage.When a user navigates to the site we have to look up his/her associated country and persist it somehow (session?).With every call to the backend we need to pass the country as a filter. When a user has more than one country associated to his/her account, we need to display a dropdownlist on the site and the user should be able to change the "current" country at any time.
I have a couple of questions:

Where exactly in the lifecycle in the ASP.NET MVC framework should I retrieve the country or countries for the currently logged on user and where should this be persisted? In ASP.NET I would solve this by creating an intercepting filter using a HttpModule to set the Countries in the session state. What is a good way to implement this in ASP.NET MVC 2? (strongly typed session state wrapper?, magic strings?)Should I put a dropdownlist for the selection of the countries in my masterpage? How can I make sure that the current country remains selected in this dropdown?How can I make sure that with every call to the backend the country is passed, should I use an action filter?

View 4 Replies

Persisting Links On An Asp.net Page -a Job For Viewstate?

Dec 29, 2010

I've got a master page with a section for subnavigation links on it:

<div id="sub_nav" runat="server"></div>


I programatically populate this with Hyperlinks when my main asp:Menu data is bound depending on the address of the page I'm on.

This works fine and all my correct submenu stuff shows up on each page. The problem is that when one of these pages does a postback, I lose all the links that were in my sub_nav div.

Now, I could just populate the div with links every time regardless of whether the master page load is a postback or not, but I figured there is a better way of doing this. I was thinking enabling the viewstate on the div and links inside it might persist them through postbacks, but apparently that is not how viewstate works.

View 3 Replies

Persisting Checkbox State While Paging In SPGridView?

Mar 23, 2011

Suppose I have created a spgridview with the following code.

[Code].....

To persist the checkbox states between pagebacks ,currently i am using session states.It has some draw backs.Now how can I persist the checked states,when the user manually checks all the checkboxes,how can i make a check on the header checkbox?

View 1 Replies

C# - Listbox Persisting Multiple Selected Items?

Jul 29, 2010

I am persisting the search selection criteria of a listbox onto another page which is called AreasLb. Multiple areas can be selected, I simply want to set the listbox items that the user selected as .Selected = true

I think the below code should work, but it doesn't, with no items in the Listbox being selected.

if (s == "Areas")
{
string[] area = nv[s].Substring(0, (nv[s].Length - 1)).Split(';');
int i = 0;
foreach (ListItem item in AreasLb.Items)
{
foreach (var s1 in area)
{
if (s1 == item.Value)
{
AreasLb.Items[i].Selected = true;
}
continue;
}
i = i + 1;
}
continue;
}

View 2 Replies

Javascript - Div's Class Not Persisting When 'back' Button Is Used?

Aug 18, 2010

I have an ASP.NET page that contains two div's. Both have search fields and a search button contained within each of them. When I first come to this page, Div A has the class 'SearchDiv' while Div B has 'SearchDivDisabled'. These classes change the appearance so the user knows which search type they currently have enabled.

When Div B is clicked, JavaScript changes it's class to 'SearchDiv', and changes Div A to 'SearchDivDisabled'. This all works like a charm. The problem I have is when a user changes to Div B, clicks Div B's search button (which obviously redirects to a results page), and then uses the browser's back button. When they return to the search page, Div A is enabled again, and Div B is Disabled, even though they last used Div B. In the search button event handler I set the class attribute of the Divs before I redirect, hoping this will update the page on the server so when the user returns, their last-enabled Div will still be enabled (regardless of which one was enabled when the page was first visited).I believe this involves the ViewState, but I'm unsure why the class attribute is not saved so when the user returns to the page it is restored.

Edit: Here is the button event handler code:

protected void RedirectToResults(int searchEnum, string resultPage)
{
ShowContainer(searchEnum);[code]....

RedirectToResults() is called from the actual button event handler with the enum representing the selected search panel and the results page url. SearchContainers is a dictionary mapping an integer to the search Div. The important code is the last line, where I'm updating the selected search container with the 'active' search class, rather than the disabled one (which I assign to the other div(s) )

Additional Update: I have been battling with this issue for the last couple days. I was sort of able to get the following code to work (in page_load):

Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.

But this really isn't a solution, as everything else that gets cached correctly is lost, which leaves me worse off than when I started. Everything else seems to persist fine, it is just the class of the div that is causing me struggles.

Edit: Just wanted to update this for anyone else that comes across this. While I believe there is a solution here with setting the cacheability of the page to force the browser to postback, I could not get it working 100% with all browsers (primarily Firefox was giving me fits, which is a documented bug). I do believe the cookie solution would work, but I felt that may be a bit more complex than necessary for just trying to store the state of a couple div's.

What I ended up doing was tying the div's class to the state of it's correlating radio button (there are radio buttons next to the div which allow the users a more visual way of enabling search panels). I noticed these radio buttons retained the correct checked value when the back button was used, so I could guarantee they would indicate the correct div to be enabled. So in JavaScript's onload I check which radio button is enabled, and then adjust the classes of the search div's accordingly. This is a pretty big hack, but has worked 100% across all browsers, and only took about 10 lines of JavaScript.

View 6 Replies

C# - Persisting Date Selections When Visible Month Changes?

Feb 21, 2011

Dim List As New List(Of DateTime)

Then in my button click event:

If InputBookinglength.SelectedValue.ToString = "2" Then
Dim paramstring As New StringBuilder
If Session("SelectedDates") IsNot Nothing Then
Dim newList As List(Of DateTime) = DirectCast(Session("SelectedDates"), List(Of DateTime))

[Code]....

This code works fine when selecting multiple days in one month. But when you switch to display a different month, the previous months selections are lost. how to persist the selections when the visible month changes.

View 1 Replies

JQuery :: Persisting CSS Change On Master Page?

Dec 23, 2010

Using ASP.Net 4.0, MVC 2, Visual Studio 2010.

I am building a chat control, which is a div with a background image, textarea, text box and some image. The CSS for this div on the Master Page is:

[Code]....

When a user navigates to the page where they can start a chat session by clicking on an icon, I use jQuery to change the CSS, like so:

[Code]....

The CSS for showing the chat is the same as the above CSS, only .chatWindowShow does not have the display:none property.

The problem is that once I navigate to another page, the div is hidden again, the CSS does not persist accross postbacks for some reason. What I want is that once the chat window is shown, no matter what other pages the users go to it will continue to show, until they click the close icon in the chat window.

So, how can I persist this CSS page accross all pages? I thought that removing the CSS class and adding the new one via jQuery actually modificate the inline HTML, but I guess not. Do I need to use some other jQuery to accomplish this?

Here is the HTML markup for my chat window:

[Code]....

And the jQuery which toggles the view when you click on the chatRight div:

[Code]....

View 3 Replies

State Management :: Persisting A Class Object?

Nov 5, 2010

I wish to persist a class object across postbacks by using a single session variable/object/whatever.

The class has about a dozen single variable properties; and about a dozen table properties; and several methods. The main table tracks rows of sporting event results. The web site will collect one row at a time for each postback. The data in the object's constructor is based on a dataset, but the data in the class will grow each time I do a postback so I don't want to loose the information in the class. The data isn't very big - it will fill a single computer screen.

Being new to programming I am thinking that I can store the dataset in the session but that would slow down the response time because I the methods would have to be called to refine the data - or maybe I can just store the entire class object in a session.

View 3 Replies

Asp.net - Persisting The List And Getting It Back In Controllers Action

Jan 12, 2011

I have an action where I get the list from the database and pass it to the view. Now, I want that when I fire another action I can somehow get hold of that list (List). How can I do that since ViewData and the TempData is erased on each request.

View 1 Replies

Web Forms :: FileUploadControl: Persisting HTTPPostedFile Across Postbacks?

Jul 9, 2010

At present i am able to persist that using session InProc mode. except that i cant use either stateserver or sql server as the HTTPPostedFile is not serilizable. i can't use viewstate either for the same reason. Is there any work around to persist that httppostedfile across postbacks for session modes other than inProc or viewstate?

View 4 Replies

C# - Persisting A Collection Backed By Viewstate In A CompositeControl?

Apr 28, 2010

Maybe it's been a long day but I'm having trouble persisting a collection backed by the ASP.NET ViewState in a CompositeControl. Here's a simplified version:

public class MyControl : CompositeControl
{
public Collection<MyObject> MyObjectCollection
{
get {
return (Collection<MyObject>)ViewState["coll"] == null ?
new Collection<MyObject>()
: (Collection<MyObject>)ViewState["coll"];
}
set { ViewState["coll"] = value; }
}
}
public partial class TestPage : System.Web.UI.Page
{
protected void btn_Click(object sender, EventArgs e)
{
myControl1.MyObjectCollection.Add(new MyObject());
}
}

When the button is clicked, the event hander btn_Click executes fine, but the setter for MyObjectCollection never gets called, hence the new MyObject() never gets persisted.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved