Forms Data Controls :: Storing A DataTable In ViewState?
Oct 7, 2010
If I create a DataTable and give each column a type, such as Boolean, String, Int32, when I store it to a ViewState Variable will those types persist?
I'm using the DataTable in conjunction with a GridView that has an add row button. I'd like to store the current state in the DataTable then bind the GridView with the previous state.
I was having trouble at first trying to store objects in the DataTable, but now I'm treating like the SQL table I will eventually write to and it's making much more sense. That's why it has fields like boolean, for checkboxes.
View 1 Replies
Similar Messages:
Sep 24, 2010
I need a bit of help with a scenario. I am working on a web application that requires huge amounts of data to be Added, Deleted, and Updated. The data entry forms are divided into logical groups through Multiviews. All the information is saved when the mighty Finish button is pressed. The current setup (previous developer) does not allow me to use transactions. Therefore, if I am to save a new Courier to the database, I need to add his/her Distance and Rate info. In addition, I need to add his/her Banned Areas info (Area Name, Post Code).This is where it gets interesting. Obviously, the DistamceAndRate table and the BannedArea table in my SQL Server will have the CourierID as a foreign key. Since I'm going to save the Courier as well as the Rates and Areas info in one go, I cannot have the newly created CourierID before. Therefore, I cannot bind my Grids for Distance + Rates and Banned Areas directly to database.What I am doing is creating two DataTables and managing them in Viewstate through properties as follow:
[Code]....
So, on page load, the DataTables are initialized with a blank schema. Here are the attempted CRUD implementations (Distance and Rate only):
[Code]....
I am having issues when I am canceling a new entry and when I am editing a new entry. In addition, for Distance and Rates, Rate is acting as unique (cannot be repeated) and attempting to control that is also giving me a headache. I end up creating blank rows.And here's the ASPX cut-out:
[Code]....
Hope to get an answer soon.Also, off-topic, I'm using LINQ here. In order to save a Courier and his/her extra details, I first save his/her address to DB. Then I take the ID of the address and save the courier. now the courier ID is avaliable and i start filling extra tables related with the courier table. If something goes wrong, I have to manually delete created rows. LINQ uses transaction internally but only until a SubmitChanges() call. I'm forced to save each entity so I keep calling SubmitChanges().I tried manual transaction but after saving the address inside a transaction, the Address.OID (Address table's mapped prime-key) had a 0. attempting to use this newly added address while saving Courier in the same transaction threw an exception. If there is a way to get the primary key for entities created in a transaction that is yet to be commited, please mention that'll as well.
View 3 Replies
Feb 23, 2011
I have a datatable with morethan 100o records and around 6 to 7 columns. When I get the data into datatable, I use each field to get distinct values and display in different drodownlists. When all the dropdown lists are filled with data, user selects one of them to filter other dropdown lists with the selected value. I want to know how can I keep datatable data stored till I get all the filtering done. I dont want to store the datatable in session as it may occupy so much of memory. Is there any other way to store the datatable till the end of the process.
View 8 Replies
Jan 1, 2010
I have a datatable dt1 which has 3 columns a,b,c( of datatype string , float ,float resp). Then I've a datatable dt2 which is clone of dt1 , and the values of dt1 is merged into dt2.
Now the issue is for a particular condition :
when the first row is this
dt1.Rows.Add("xyz", 0.0, 0.0);
But I can see the value is taken as xyz,0,0 in the datatable. This i am merging to dt2 as
if (dt2 == null)
{
dt2 = dt1.Clone();
}
dt2.Merge(dt1, true);
Now when I merge for the second time with say some vale in dt1 as ("mnp",4.5,8.9) i get an error at dt2.Merge(dt1, true);
Error: .b and .b have conflicting properties: DataType property mismatch.
where b is the column name.
Have defined the table dt1 as :
DataTable dt1 = new DataTable();
dt1.Columns.Add("a", typeof(string));
dt1.Columns.Add("b", typeof(float));
dt1.Columns.Add("c", typeof(float));`
View 2 Replies
Apr 2, 2010
If I am passed a datatable and I cant change the column structure..is there anyway to set an existing column to a Primary key so I can easily Find() the row I am looking for?
View 1 Replies
Jan 19, 2011
i have a list for my shopping cart which i currently store in my datatable and then store it in a session. to avoid using sessions is it best to create a class where the datatable is stored and can be accessed from anywhere?
View 2 Replies
Oct 28, 2010
I am storing Datatable in Session variable in my project. Is it good practise to do so? The datatable has 20 fields and can run into 1000+ records. Will it hamper my application performance?
View 11 Replies
Feb 24, 2010
Consider my dataTable contains 10,000 rows and i want to know the pitfall of storing datatable in a session variable... I want to use it until a new row has been added...What type of session mode should i use?
View 4 Replies
Jan 26, 2011
I have a dataset which consists of a set of records. I have put this dataset records in a viewstate so that I can access it from a different method on the same page.
ds = TelephoneDtl.GetTelephoneData();
ViewState["CurrentPos"] = ds.Tables[2];
I now want this view state values to be assigned to a datatable. Something like this:
datatable dt = ViewState["CurrentPos"];
But doing this gives me a typecast error
View 4 Replies
Jan 11, 2010
i have the dataset with one table.Table contains three column like 'Name','Location','Pin'.I would like to move the data from another table based on schema.
View 2 Replies
Aug 22, 2012
im trying to copying specific record from one datatable to another datatable i used below code
public System.Data.DataTable selectspecificdatarow(System.Data.DataTable dtg, int count, int startindex)
{
System.Data.DataTable dtn = dtg.Clone();
for (int i =startindex; i < count; i++)
[Code]....
its taking too long time in cloneing is there any better way to do this task which is Time effecent
View 1 Replies
Aug 27, 2010
I am retrieving data from a web serivce and storing the data into a dataset.
I'm then populating a gridview with the data from the dataset.
Before each row of data is displayed on the website, I need to check and make sure the user has proper permissions to view that data.
Can this be done with a gridview(or any other .NET data control)?
Or would I need to loop through the data manually, and then write each row out manually?
View 3 Replies
Jan 27, 2010
I want to store Date as well as time in a label. The code that i am writing is Label1.Text = Datetime.Now.ToString();
I want to save this value in to the database. This is what i am writing
com.Parameters.Add ("@Dt ", SqlDbType.datetime).Value = label1.Text; // this is the problem.
View 6 Replies
Jul 8, 2010
How do I store an Eval in a variable or use the value of the Eval in an if statement?
View 5 Replies
Nov 25, 2010
i m using sql server 2005 and asp.net 2.0.
i want to store text data with paragraphs as it is in sql server and retrive it .
want to show that data with paragraphs in .net again.
View 2 Replies
Feb 11, 2010
I've been strugglying with this for some time now and I cannot seem to find what I'm doing wrong. I have a gridview with a hyperlink field, so when the user clicks on the hyperlink it takes them to the next page but I want to store 2 field value's in session. I've tried it the url way but I get a "Input string was not in a correct format"
and for security reasons I dont think its the best way, the only other way is for it to be stored in session.
View 7 Replies
Jan 20, 2011
'DataTable' is an ambiguous reference between 'System.Data.DataTable' and 'Microsoft.Office.Interop.Word.DataTable'
View 3 Replies
Feb 3, 2010
I have webpage containing 3 views of multiview control. In the first view there are 3 fields Name Age Surname
which will be captured in the textbox for the respective fields.In the second view i have three more fields
sex
maritalstatus
bloodgroup
which will be entered in the respective textboxes and a submit button to store the data in both the views in the sql server database. I have all the fields in the sql server table which are mentioned in the webpage.I need the complete code for storing the entered data in both the views of the multiview control after hitting the submit button.
View 1 Replies
Sep 20, 2010
i have a grid view with radio button...schedule/approve/reject...by defualt schedule radio button is selected....but when i chage radio button selection option to anyth other than schedule it still store only schedule in DB.wats the pblm?
[Code]....
[Code]....
when i click submit button i got this error
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
so i set the enableeventvalidation=false
now i dint receive any error but when i set breakpoint on the funtion which called on buton clik it still got the value as scheduled for the radio button..spent almost half day for this.. all this while this was workin after i add the moralpopupextender am facing this pblm...now i tried removin that extender but still pblm exist.
View 5 Replies
Dec 15, 2010
I am working on the application that allows user to upload a file (from their local machine) and store the uploaded file in database.Then,the content of the file (such as ContentType,FileSize etc)can be view in a DetailsView control.
View 1 Replies
Aug 16, 2010
I have a column with nvarchar datatype storing the date. I am using a Gridview to display and edit data of that table. Now when I update the table the nvarchar column containing date in the format mm/dd/yyyy gets converted to Jun 9 2010 12:00AM format. I don't want this to be happening. I don't understand why this is happening as I don't have datetime column.
View 4 Replies
Mar 30, 2011
I have a GridView that shows results according to user selections above it via checkboxes, dropdown lists etc. Once user clicks on a hyperlink value on one of the rows in GridView, user is taken to another page which is sort of a drill down for that line item in the GridView.
Everything works fine so far, except when the user hits the back button, user selections that filter data on the Gridview page are lost. So, I added ViewState="True" on these filter options (i.e. checkbox, dropdownlist etc.). When back button is hit selections were still cleared. How could I remedy this?
View 2 Replies
Apr 8, 2010
I've got a GridView on my page which has some bound controls, one of which is a label (to display total price):
[Code]....
However this value is not being passed to my page. All I see is '£' symbol, no price which makes me think Viewstate["youpay"] is empty? I have enabled viewstate on the Page and Control tags.
View 3 Replies
Apr 22, 2010
I am creating a gridview dynamically in a custom control and adding it to a Panel. I set the EnableViewState = true. The problem is that on a page postback the GridView does not seem to retain its values. If I add a GridView through the UI then the viewstate is preserved. The problem seems to occur when it is put dynamically only.
View 2 Replies
Jan 31, 2011
If I disable the ViewState on a ListView, the events raised by it are no longer ired. OnPagePropertiesChanging is the ListView event I've always used in combination with the DataPager to update the ListView to the correct page once a DataPager item is clicked, but since its not being fired, I'm wondering if there are any other options. My ListView is currently in an UpdatePanel, and I'm caching the results that the ListView is being bound to. I could rebind the cached results on the PageLoad, but I can't think of a good way to determine if the PageLoad is being accessed because the DataPager was clicked, or for some other reason, so this doesn't seem like a good idea
View 2 Replies