I implemented Grid with update option. When I click on update symbol in row I am getting One checkbox for update (I use SQL data source only with one column to update).
I have two issues with this approach:
1. Checkbox is not checked by default, how can I change this?
2. I see two commands Update and Cancel, how I can remove Cancel?
I have two issues with this approach:
1. Checkbox is not checked by default, how can I change this?
2. I see two commands Update and Cancel, how I can remove Cancel?
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 20 Sep 2012, 08:17 AM
Hi Berto,
I suppose you are using CheckBoxColumn. Here is the sample code.
C#:
Thanks,
Princy.
I suppose you are using CheckBoxColumn. Here is the sample code.
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode )
{
GridEditableItem item = (GridEditableItem)e.Item;
LinkButton cancelButton = (LinkButton)e.Item.FindControl(
"CancelButton"
);
//accessing cancel button
cancelButton.Visible =
false
;
CheckBox chk = (CheckBox)item[
"Uniquename"
].Controls[0];
//accessing checkboxcolumn
chk.Checked =
true
;
}
}
Thanks,
Princy.
0
berto
Top achievements
Rank 1
answered on 29 Sep 2012, 04:20 PM
Thanks for quick reply.
I have some issue to identify correct name of "CancelButton" and what _i should put in place of "Uniquename"?
I have some issue to identify correct name of "CancelButton" and what _i should put in place of "Uniquename"?
0
berto
Top achievements
Rank 1
answered on 29 Sep 2012, 04:45 PM
Cancel button has disappeared. my checkbox however is still not checked.
My code:
Fertig is name of the column which should be updated.
My code:
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
LinkButton cancelButton = (LinkButton)e.Item.FindControl(
"CancelButton"
);
//accessing cancel button
cancelButton.Visible =
false
;
CheckBox chk = (CheckBox)item[
"Fertig"
].Controls[0];
//accessing checkboxcolumn
chk.Checked =
true
;
}
Fertig is name of the column which should be updated.
0
berto
Top achievements
Rank 1
answered on 29 Sep 2012, 04:58 PM
I changed to In-line editing mode. Now i assume cancel button is called differently ass even this part of the code does not work.
0
berto
Top achievements
Rank 1
answered on 29 Sep 2012, 08:04 PM
I fixed first issue, so I don't see any more Cancle Icon. However still have issue with check box which is not checked.
This is code I am using:
When I use chk.Visible = false; however checkbox disappears.
I checked this issue as well in debugger and there chk.Checked has value True.
This is code I am using:
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
ImageButton cancelButton = (ImageButton)e.Item.FindControl(
"CancelButton"
);
//accessing cancel button
cancelButton.Visible =
false
;
CheckBox chk = (CheckBox)item[
"Fertig"
].Controls[0];
//accessing checkboxcolumn
chk.Checked =
true
;
}
When I use chk.Visible = false; however checkbox disappears.
I checked this issue as well in debugger and there chk.Checked has value True.
0
berto
Top achievements
Rank 1
answered on 01 Oct 2012, 07:58 PM
I have got reply from support. Code was ok only placed in wrong method. It should be RadGrid1_ItemDataBound not ItemCreated.