i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programatically hide gridview row c#
04-04-2011, 07:27 AM
Post: #1
Programatically hide gridview row c#
i saw many developers struggle when they are playing with bulk database and when some one delete the row from front end (in gridview), and require to bind the gridview again with database (this decrease the performance of application and bad impact on user usability)

so the better solution is delete the row from database (this take less time) and instead rebinding the gridview from database, simply hide the row in front of user

advantage:
1- application performance
2- increase user usability
3- less load on database

Code:
protected void btn_Remove_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvrow in GV_MailList.Rows)
        {
            CheckBox CB_SelectRecord = (CheckBox)gvrow.FindControl("CB_SelectRec");
            if (CB_SelectRecord.Checked)
            {
                //call delete function to delete from database
                gvrow.Visible = false;
            }
        }
    }
GV_MailList = GridView Control
This function does not required to rebind the gridview again, this trick is also effective on small databases.



[Image: 2604595733.png]
Quote
04-04-2011, 09:20 AM
Post: #2
RE: Programatically hide gridview row c#
Hi Nisar !!

Very useful .This code is very neccessary if we are using gridview.

Cheers!!!!!!
Rajesh Kumar Parbat
Quote
04-05-2011, 12:14 AM
Post: #3
RE: Programatically hide gridview row c#
good one..


Thanks and Regards
Raju
Quote
04-21-2011, 01:10 PM
Post: #4
RE: Programatically hide gridview row c#
hi
nisar good code really but when will post page load all record how to restrict them.
Quote
04-21-2011, 02:52 PM
Post: #5
RE: Programatically hide gridview row c#
@jayakumar

you will load all record only when page will open first time.
like below
Code:
if(!ispostback)
{
  fnc_loadgrid();
}

fnc_loadgrid(); is the function which will load all data in grid. after load the data in grid, you dont need to load the data again on deleting any row.

please let me know if you have any query ...

[Image: 2604595733.png]
Quote
04-22-2011, 09:51 AM
Post: #6
RE: Programatically hide gridview row c#
hi
nisar good one i have already know ispostback method i have little bit idea this is good or not i do know
if this is good accept not means asked another way in advice for me.

when will we are click check visible record that time same datatable corresponding row dynamically update any one flag field set like this disable - D , enable - E then when we have load datatable we are using dt.select which record
have E that records only show this is best way or not i do know may be this is good do and send Me.
Quote
04-22-2011, 10:14 AM
Post: #7
RE: Programatically hide gridview row c#
ispostback property indicates whether the page is being rendered for the first time or is being loaded in response to a postback.

postback is a process of client to server request, and server to client response.

if(!ispostback)
{
//first time this condition will true, because yet there is no request sent from this page to server
}

but if you will click on delete, disable etc on grid, request will send from client to server, and this condition will false this time.

now my purpose of above post was to reduce the load of calls on database as well as on server. normally developers bind the grid again after deleting or updating any record inside the gridview, so user will facilitate with updated data, but i am doing the same without binding the data again to grid, i was just hiding the row from user after deleting the records, hiding the row is much faster then binding the grid again from database, if you have bulky database as well as want to delete few records one by one.

please let me know if you still have some doubts.

[Image: 2604595733.png]
Quote
04-26-2011, 11:59 AM
Post: #8
RE: Programatically hide gridview row c#
Nice Sharing Nisar

Oracle Certified Trainer
[Image: signature.php?uid=40]
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  why do not SetFocus row for the GridView when using the Thread ? dongtrien 0 1,229 12-10-2015 08:16 AM
Last Post: dongtrien
  Read, write and processing each row of a gridview ? dongtrien 0 1,286 11-24-2015 03:16 AM
Last Post: dongtrien
  Select GridView Row without using Select button raju 1 5,331 09-04-2010 04:04 PM
Last Post: nisar87



User(s) browsing this thread: 1 Guest(s)