Dynamic columns in grid view
-
Hi, I wrote a function for dynamically create some bound columns and template field in grid view.The template field having check box in header template and item template. First i have called this function on Page_load (!IsPostBack). This will work fine. Then i have checked the check box and click on a button(for delete the checked rows), the check box disappers.After the click event,if i am trying to access the check box from page load ,it returns null.I couldnt access the dynamically created checkbox . Why it happening? How will i solve this problem? Thanks
-
Hi, I wrote a function for dynamically create some bound columns and template field in grid view.The template field having check box in header template and item template. First i have called this function on Page_load (!IsPostBack). This will work fine. Then i have checked the check box and click on a button(for delete the checked rows), the check box disappers.After the click event,if i am trying to access the check box from page load ,it returns null.I couldnt access the dynamically created checkbox . Why it happening? How will i solve this problem? Thanks
See when you click a button or and the page loads what ever is there inside !isPostback will be discarded. You will require to call the binding function in the button click event to get it created again. Or put it outside !IspostBack
Thanks Laddie Kindly rate if the answer was helpful
-
See when you click a button or and the page loads what ever is there inside !isPostback will be discarded. You will require to call the binding function in the button click event to get it created again. Or put it outside !IspostBack
Thanks Laddie Kindly rate if the answer was helpful
Hi, Thanks for you reply.But there is another problem. In the buttton click, all other columns expect template field is there as such. The template column is there ,but the control is invisible.If i am creating the control outside !ispostback then i couldnt get the checked row for deletion. How will solve this.
-
Hi, Thanks for you reply.But there is another problem. In the buttton click, all other columns expect template field is there as such. The template column is there ,but the control is invisible.If i am creating the control outside !ispostback then i couldnt get the checked row for deletion. How will solve this.
jinovv wrote:
If i am creating the control outside !ispostback then i couldnt get the checked row for deletion.
Are you creating dynamic controls ? If yes this would be a viewstate problem. Controls created in
page_load
event won't maintain viewstate. Try any event which fires before viewstate is saved.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions