|
Why use a loop ??!!
Just Bind directly
ResultsDataGrid.DataSource = Results;
ResultsDataGrid.DataBind();
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Got the solution. I made a relation datatable and then used it.
thanks
Regards,
Pavas
|
|
|
|
|
Hello ,
I need some recommendation on retriving data from DB , before today , I take my data from db using data adapter and put it on a datatable and return it to a grid and bind to that grid. From this day , I tried something different and I put entity classes on my application. I created an arraylist which contains those entities and return that arraylist to the grid and bind it. I read somewhere with this kind of binding will be faster than datatable binding. (I am not quite sure yet with this because I could get all the story wrong )
In long story short : I retrive data from my DB using data adapter then fill a data table and then I fill my entities from that data table then create an arraylist then bind it.
Is there any faster (efficient) way to fill my entities or is it the way everyone does?
thanks for your replies.
Revelation 22:13
|
|
|
|
|
Using Entity Class is faster , for sure ..
But as I think it won't be that flexible because tommorow if you make some modification in the StoredProcedure returning some new columns from your SP,
Then u have to make same Changes in your entity class .........
|
|
|
|
|
One Suggestion : You can use caching for improve the Performance of your web application. As per your desing, For Every Request if client need data, it will goes to DataBase Server and then retreive data from there.
My Suggestion, use caching and store data over there, access data from cache. Which will increare performance dramatically.You can Read This Article [^]
Update the cache on aspecific time dealy.
Hope It will help You !!!
|
|
|
|
|
Tugbay Sahin wrote: I retrive data from my DB using data adapter then fill a data table and then I fill my entities from that data table then create an arraylist then bind it.
This is going to be slower. You are doing one step extra.
DataTable is filled using a data reader instance internally. So when you retrieve 10 records from DB, you will loop 20 times to fill your entity class (10 for filling datatable and 10 for filling class from this datatable).
When you use strongly typed entity classes, you don't need data table at all. You get the result in data reader, loop through it and fill your custom class instances. Don't use ArrayList , use a generic List(T) instead. This should be much faster.
Example (Assuming Customer is your entity class with two properties name and age)
public List<Customer> GetCustomers(){
List<Customer> customers = new List<Customer>();
using(SqlDataReader reader = command.ExecuteReader()){
if(reader.HasRows){
int customerName = reader.GetOrdinal("name");
int customerAge = reader.GetOrdinal("age");
while(reader.Read()){
customers.Add(new Customer(reader.GetInt32(customerAge),
reader.GetString(customerName));
}
}
}
return customers;
} Data table is not type safe. This method will help you to avoid many bugs and your code will look much cleaner.
Hope this helps
|
|
|
|
|
Thank you very much for your answers. I got my answer(s)
other recommendations always welcome from me ^^
Revelation 22:13
|
|
|
|
|
Dear Guy,
you came to a good point
Actually DataSets, DataTable, .. are bad for both performance and memory
And you toke a good step by creating Entity classes
But you still use the datatables .. so, you added an overhead as Navaneeth said
There is a free open source framework that handles this for you
It is CSLA try this http://www.lhotka.net/cslanet/[^]
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
I am working in asp.net 2.0
I have an iframe on my page, How can I retrieve the source code of the content in this iframe. Source(src) of this iframe is in different domain.
Thanks in advance.
|
|
|
|
|
I would do a document.getElementBydId("iframeId").innerHTML.
|
|
|
|
|
|
In JScript it's innerHTML
As far as I know, document.getElementById is a jscript method
|
|
|
|
|
Why do you use IFrame? use MasterPage instead
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Hi,
I have a regular expression for entering decimal values with exactly 2 digits after the comma.
[0-9]{1,4},[0-9]{2}
"1.34" -> ok
"9765.51" -> ok
"67453.56" -> nok
"-7.45" -> nok
"67.1" -> nok
"" -> ok I would like that to be nok.
My problem is that even when I enter nothing (empty string) it passes the test.
How can I prevent this from happening.
tia
|
|
|
|
|
Check this page http://regexlib.com/[^]">
One thing also you can do before passing it to regex check whether it is empty string and implement accordingly
Cheers!!
Brij
|
|
|
|
|
i want to create a file list which will display all the files of any any perticular folder.how can it be possible in asp.net
|
|
|
|
|
Assuming you mean files on the sever, this is one way:
DirectoryInfo d = new DirectoryInfo(_basePath);
foreach (FileInfo f in d.GetFileSystemInfos("*.csv"))
{
...../do what you want here
}
Bob
Ashfield Consultants Ltd
|
|
|
|
|
when i testing the application from VS2005 it is run ok and send the message to the email.
but in the dam server it is give me this error.
the error:
User not local; please try a different path. The server response was: Sender address is not valid for your login. Check your email program settings.
any help please.
thanx in advance
|
|
|
|
|
It seems you have to change the Host of your SmtpClient
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Hi,
I am looking at ways to align the AJAX UpdateProgress next to the button that is doing a server postback, but not having success.
I first added the UpdateProgress above the UpdatePanel in the masterpage (use one masterpage with an updatepanel), but when I click the button, the UpdateProgress image was displaying at the top. I then moved it next to the button(on the page that was doing the postback), but then had a few of these UpdateProgress images displaying to the "submit" buttons (there are 3 of these on the page).
Does anyone know how to get passed this?
Thank you.
|
|
|
|
|
Dear all
I made application with these steps in this below url which is working perfect.
http://weblogs.asp.net/dwahlin/archive/2005/11/16/430779.aspx
but when i added big html which cantain like it gives error below
"An error occurred while try to load the string resources (FindResource failed with error -2147023083)"
Please tell us why the above error is comming.
Zafar
|
|
|
|
|
Keep the Images folder also under the same folder where your master page is available.
|
|
|
|
|
Please Explain more please
|
|
|
|
|
ALAQUNAIBI wrote: but when i added big html which cantain like it gives error below
"An error occurred while try to load the string resources (FindResource failed with error -2147023083)"
Image path that you given is not valid. please verify that path.
|
|
|
|
|
If your Master Page is under root directory, then Create a folder images under root directory and now refer this path for your image.
You should not face any problem.
|
|
|
|