Hi,
I am trying to have a display data in a table inside a update pannel. Basic idea is to get refreshed data and display for user. So far so good. But i want to heighlight the data that is changed since all data may not change everytime though its fetched everytime. How do i chk if data is changed or not ? since each time what i have is only updated value from database. I tried storing data in simple hidden input field dynamically, but as its refreshing only part of page, its not posted, and i could not access it. Does anybody know a way to do this in better way ?
Thanks :)
This is just a thought and I dont know if it will work or not, but maybe use two Datasets, one dataset for the currently displayed data and the other dataset for the new/pending to display data. Itterate though both in a loop, compare the values in the same index postion and if they are different, make your style changes, otherwise, make no style changes. As you itterate though the loop, copy the value from the new/pending dataset to the current dataset. Your new/pending dataset becomes the old one. Although, I think this might need more thought than what I simply typed here.
You may want to go with a similar approach still using the current dataset and the new/pending dataset but create an array that contains the data with its style that you are going to display. You still do the comparison as I mentioned above, but instead of changing the dataset, you change the values in the array. After the comparsion is complete, you render the table based on what is in the array. You then close the old data set or make its data source be that of the new/pending data source.
Another option, instead of using the array is to build the table dynmaically and storing the the values in there as apposed to the array. You have to store the values somewhere so why not store them in the object that you plan to render anyways. This I am assuming you are creating your tables like this: Table tbl = new Table TableRow tr= new TableRow
I wanted to give you a few options but I think the last one is your best one. With the last option you may not even need two datasets, you only need your new/pending one and you always compare it with what is in the value of your TableCell. This will only work if you are using Table Controls as apposed to creating yoru tables like so: string strTable += "<td>" + strSomeValue + "</td>";
If you need further help on the thrid option (Using a table control with one dataset) let me know. I think this is the best way to go.
Good luck!
Thanks really for that quick reply. I would like to try on the array meathod, since in this application i'm anyway gonna strain the db by calling refreshed entries every 3 seconds, from 100s of users at a time. So i guess array will be managible. But can u help me a bit further as to how i create an array that has dynamic number of elements, since for every user it'll be different no of elements, depending on wht he has opted for.
shiloo75:
I tried storing data in simple hidden input field dynamically, but as its refreshing only part of page, its not posted, and i could not access it.
The hidden input value is posted even when it is outside of your updatepanel!
You can get the value of the hidden field this way:
Page.Request.Form.Get( "your field's id" )
No comments:
Post a Comment