Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I have Gridview with data and placed a dropdownlist box in the Gridview.
This dropdownlist box value is loaded from DB.
Eg - Values are :
ABC
XYZ
123

But if my Gridview is having a 100 rows then each time its loading the DB for each dropdownlist box.
Values has to be loaded only once at the time of page load.
I am planing to store the values in Temp table and array, then use the variable for the filling the dropdownlist box.

Can you people guide me on this or give me a better solution.
Posted
Comments
TrushnaK 12-Dec-13 3:07am    
I hope you have write your code in page_load() event
and check is postback
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack) {
//Bind your grid view and ddl
}
}
Arunprasath Natarajan 12-Dec-13 8:35am    
You didnt got my question. Sorry if i am not clear.

Hi Arun,

What I would like to suggest here is, Yes you can.
You can try another way to bind list to drop down like this

1) Get values from DB for dropdownlist and assign it to a list
2) Now get values for gridview and bind it.
3) Once all dropdown list is loaded assign a class to it.
4) Now by class assign list value to each and every dropdownlist in the gridview.

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
Comments
Arunprasath Natarajan 12-Dec-13 8:34am    
Looks cool. Can you give me a sample example.
♥…ЯҠ…♥ 12-Dec-13 8:37am    
You should try with your code,since I dont have any schema or anything.Here I can give idea you must implement it.
Arunprasath Natarajan 12-Dec-13 9:13am    
Ok will try and get back to you.
Hi Try it:
C#
if (!IsPostBack) {
                    //Bind your grid view and ddl
    }

Yours Farhad.
 
Share this answer
 
Comments
Arunprasath Natarajan 12-Dec-13 8:35am    
You didnt got my question. Sorry if i am not clear.
use array to fetch the value from database and then this arrray assign to gridview
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900