there i have another problem:
mygridview is populated ok , but works very slowly. I need to have about20 - 40 textboxes and dropdownlists on my page. i put on page ascriptManager and all control are putted in an UpdatePanel . when isearch a item in database , my gridview is populated very slowly..
it seems is related about viewstate, but i don`t know exactly...i need some help.
what is wrong?..how can i fix this problem?
Hi,
how's your network behaving? Did you also use SQL profiler to see how many sql requests there are executed when you update your grid? Try to split up all the controls in logical groups and use multiple updatepanels on your page. Also insert an UpdateProgress control so that an enduser sees that something's going on and needs to wait a bit.
Also know that a downside of the updatepanel control is that it goes through all events of the page life cycle up until the render event where it only renders the specific controls. Most knowledgable is that indeed ViewState is always sent back and forward so you don't gain any performance on that part by using the UpdatePanel.
Grz, Kris.
I made all controls from page with enableviewstate = false;
i put my grid ,textbox where i enter the text which is searched in database, and button to click in a update panel, and all textboxes in a another update.
When i search a text in database it works fine, my gridview it`s populatede relative quicly , but when i click on a item from gridview works slowly. :(
it could be from that connection to database(stored procedure)?
i really need some help...plsss...
this is the code that i use it:
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
FillTextBoxes();
UpdatePanel2.Update();
selected = gridview.SelectedValue;
}
protected void FillTextBoxes()
{
ArrayList textBoxesArrayList = new ArrayList(18);
ArrayList dropDownsArrayList = new ArrayList(6);
for (int i = 0; i < 18; i++)
textBoxesArrayList.Add((object)UpdatePanel1.NamingContainer.FindControl("TextBox" + (i + 1).ToString()));
for (int i = 0; i < 5; i++)
dropDownsArrayList.Add((object)UpdatePanel1.NamingContainer.FindControl("DropDownList" + (i + 1).ToString()));
SqlConnection conn = new SqlConnection();
ConnectionStringSettings stringToConnect = ConfigurationManager.ConnectionStrings["ConnectionString1"];
conn.ConnectionString = stringToConnect.ConnectionString;
conn.Open();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.CommandText = "GetDetails";
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Connection = conn;
SqlParameter sqlParam = new SqlParameter();
sqlParam.ParameterName = "@.searchCriteria";
sqlParam.DbType = DbType.String;
sqlParam.Value = selected.ToString();
sqlCommand.Parameters.Add(sqlParam);
SqlDataReader rdr;
rdr = sqlCommand.ExecuteReader();
while (rdr.Read())
{
int i;
for (i = 0; i < textBoxesArrayList.Count; i++)
((TextBox)textBoxesArrayList[i]).Text = rdr[i].ToString();
for (int j = i; j <textBoxesArrayList.Count + dropDownsArrayList.Count; j++)
((DropDownList)dropDownsArrayList[j - textBoxesArrayList.Count]).SelectedValue = rdr[j].ToString();
}
Hi,
did you already used SQL profiler to see what gets called for 1 page on the database? It could be that you're generating a lot of commands that could bring SQL server to its knees. Also be sure to always close your connection. For this it's best that you use theusing() statement which disposes of your valuable resources itself.
Grz, Kris.
i have :
conn.Close();
and the select from database is simple... what to put in that using??
Theusing statement allows the programmer to specify when objects that use resources should release them. The object provided to theusing statement must implement theIDisposable interface. This interface provides theDispose method, which should release the object's resources.
i don`t use resource and ArrayList don`t implement that interface...that`s i think that is not a solution available for this problem
Hi,
dany_soft_2002:
i don`t use resource and ArrayList don`t implement that interface...that`s i think that is not a solution available for this problem
actually you do, by using the SqlConnection class. But the using statement had more to do with the Close() method of the connection.
Did you already check with SQL profiler what the load on the database server is?
Grz, Kris.
"Did you already check with SQL profiler what the load on the database server is?"
what did you meen, how many records have table in which i made that select?.. if you refer to this , answer is about 20.000.
i put in
using (SqlConnection conn = new SqlConnection())
and all that try in this using. it should to put every textbox, dropdownlist that i have in a using statement??
all is the same, until now...:( :(
Hi,
no, what I mean is, how many queries are executed while you're performing this action? You can see that by using the tool SQL profiler.
Also, how much time does it take to complete this method.
And yes, everything else goes inside the using statement.
Grz, Kris.
i put:
using (SqlConnection conn = new SqlConnection())
and in this using i put:
while (rdr.Read())
{
int i;
for (i = 0; i < textBoxesArrayList.Count; i++)
using ((TextBox)textBoxesArrayList[i])
{
((TextBox)textBoxesArrayList[i]).Text = rdr[i].ToString();
}
for (int j = i+1; j < textBoxesArrayList.Count + dropDownsArrayList.Count+1; j++)
using ((DropDownList)dropDownsArrayList[j - textBoxesArrayList.Count])
{
((DropDownList)dropDownsArrayList[j - textBoxesArrayList.Count]).SelectedValue = rdr[j].ToString();
}
}
what i found:
i have a dropdownlist populated with 20.000 record . when i remove from my page this dropdownlist, everything works fine. (first dropdownlist from that array)
but, i need dropdown...how to do ??
now i search on web about sql profiler, and i will tell you the answer.
Hi,
dany_soft_2002:
i have a dropdownlist populated with 20.000 record . when i remove from my page this dropdownlist, everything works fine. (first dropdownlist from that array)
but, i need dropdown...how to do ??
20.000 records into one dropdownlist? No wonder you're having problems. If it really needs to be that many I suggest that you rethink your application because no one will be able to find the specific data (s)he needs in such a large list. I propose that you split them up in categories and subcategories so they become more maintainable. Then you can use the Cascading dropdownlist extender to first choose a category, then a subcategory and finally the one that the user's after.
So don't bother to choose any further for SQL profiler for the moment but first tackle that dropdownlist problem! Besides that SQL profiler ships with SQL server so you need to install it on your pc.
Grz, Kris.
i tried to reduce the number of records from that dropdownlist. it work`s faster. Thx a lot for your time.
Give me some links, from where to study about sql profiler...have something like that?
Hi,
you can begin withMonitoring with SQL profiler. Or google for it:http://www.google.be/search?hl=en&q=using+sql+profiler&meta=.
Grz, Kris.
i found the problem:
i have a dropdownlist and when i`m databinding it , it will have about 5000 of records. when i remove this databinding all works fine.
what can do i to improve this dropdownlist??
Hi,
dany_soft_2002:
i found the problem:
i have a dropdownlist and when i`m databinding it , it will have about 5000 of records. when i remove this databinding all works fine.
what can do i to improve this dropdownlist??
I thought we were clear on this matter. Please do as I suggested in my former post:
... it really needs to be that many I suggest that you rethink your application because no one will be able to find the specific data (s)he needs in such a large list. I propose that you split them up in categories and subcategories so they become more maintainable. Then you can use the Cascading dropdownlist extender to first choose a category, then a subcategory and finally the one that the user's after.
With other words, don't try to have more than 100 items in your dropdownlist. Maybe a bit more but certainly not thousands.
Grz, Kris.
No comments:
Post a Comment