Hello!
I added a checkbox to "CommandItemTemplate". Now I need to get the value wether it's checked or unchecked in "Page_Load". But how can I access the control with Page.FindControl("FromName"). FindControl("CheckboxName") the control couln't be found. Any ideas?
Thanks in advance
I added a checkbox to "CommandItemTemplate". Now I need to get the value wether it's checked or unchecked in "Page_Load". But how can I access the control with Page.FindControl("FromName"). FindControl("CheckboxName") the control couln't be found. Any ideas?
Thanks in advance
7 Answers, 1 is accepted
0
Hi Markus,
You cannot access the checkbox in the pageload event. You can however access it in a later event. This may look something like:
.cs
I hope this information helps.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You cannot access the checkbox in the pageload event. You can however access it in a later event. This may look something like:
.cs
| protected override void OnPreRenderComplete(EventArgs e) |
| { |
| base.OnPreRenderComplete(e); |
| GridCommandItem commandItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; |
| CheckBox cb1 = (CheckBox)commandItem.FindControl("CheckBox1"); |
| Response.Write(cb1.Checked); |
| } |
I hope this information helps.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 1
answered on 07 Mar 2008, 12:14 PM
Hello Yavor,
thanks for help, this is what I need, but it is not working, because on a postback the status of the checkbox will not be saved, only if I put the checkbox outside the CommandItemTemplate of the grid. Any Ideas?
Regards Markus
thanks for help, this is what I need, but it is not working, because on a postback the status of the checkbox will not be saved, only if I put the checkbox outside the CommandItemTemplate of the grid. Any Ideas?
Regards Markus
0
Philip
Top achievements
Rank 1
answered on 19 Mar 2008, 02:56 PM
Hello Markus,
could you solve your problem with the not saved checkbox?
I have the same problem with a Combobox.
Dear Telerik-Team: do you have an idea?
Thank you and with kind regards,
Philip
could you solve your problem with the not saved checkbox?
I have the same problem with a Combobox.
Dear Telerik-Team: do you have an idea?
Thank you and with kind regards,
Philip
0
Markus
Top achievements
Rank 1
answered on 19 Mar 2008, 03:10 PM
Hello Phillip,
I still wait for a solution of this problem but got no answer from telerik team up to now.
Currently I use the following workarround: I placed the checkbox outside the grid. I enabled absolute positioning for the textbox and set the position in code behind. This is not very nice because if you change your page you have also to change the absolute position each time and in my case is not correct in any case on some ajax requests the position change. But I found now better solution.
Regards Markus
I still wait for a solution of this problem but got no answer from telerik team up to now.
Currently I use the following workarround: I placed the checkbox outside the grid. I enabled absolute positioning for the textbox and set the position in code behind. This is not very nice because if you change your page you have also to change the absolute position each time and in my case is not correct in any case on some ajax requests the position change. But I found now better solution.
Regards Markus
0
Hello Markus,
When you make a Postback, the state of the checkbox in the CommandItemTemplate will be saved. You'll loose its value only if you explicitly rebind the grid or if it is implicitly rebound from some grid command.
But to save the value of your checkbox, you can use the ViewState or save it in a Session as well. Thus there will be no need to put it outside the grid.
Sincerely yours,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
When you make a Postback, the state of the checkbox in the CommandItemTemplate will be saved. You'll loose its value only if you explicitly rebind the grid or if it is implicitly rebound from some grid command.
But to save the value of your checkbox, you can use the ViewState or save it in a Session as well. Thus there will be no need to put it outside the grid.
Sincerely yours,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 1
answered on 25 Mar 2008, 10:40 AM
Thanks for help I get it work now. I save status of checkbox now in "PreRenderComplete" and restore it in "SaveStateComplete".
There is still a small thing. If I databound the grids in "PreRendercomple" the grid always shows an additional empty row (no data no grid lines). Why is this row available and how can I remove it?
There is still a small thing. If I databound the grids in "PreRendercomple" the grid always shows an additional empty row (no data no grid lines). Why is this row available and how can I remove it?
0
Hi Markus,
I suggest that you use the NeedDataSource event of RadGrid to bind it to its data. This is described in this online help resource. Then, in the PreRenderComplete handler, you can just Rebind() it. Thus you can be sure the data will be bound and displayed properly.
I hope this suggestion helps.
Sincerely yours,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I suggest that you use the NeedDataSource event of RadGrid to bind it to its data. This is described in this online help resource. Then, in the PreRenderComplete handler, you can just Rebind() it. Thus you can be sure the data will be bound and displayed properly.
I hope this suggestion helps.
Sincerely yours,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center