Hi,
I have created my own custom RadGrid column control by extending GridEditableColumn class. I have placed two label controls in the cells. I have used InPlace edit mode for the grid. I have used the labels for edit as well as non edit mode for the cell. These controls show up in the page for both edit as well as non edit modes. The problem I'm facing is , whenever I fire the insert or update commands, the GridDataItem(from e.Item) shows that the cell contains no controls. Could somebody please help me on how to maintain the controls when the Insert or Update commands are fired.
Also once this is done I would also like to know, which method to override or event to register to, so that when I call the ExtractValues method on the GridDataItem(from e.Item) object, I get the value from that specific control in the cell that I will decide.
Thanks
I have created my own custom RadGrid column control by extending GridEditableColumn class. I have placed two label controls in the cells. I have used InPlace edit mode for the grid. I have used the labels for edit as well as non edit mode for the cell. These controls show up in the page for both edit as well as non edit modes. The problem I'm facing is , whenever I fire the insert or update commands, the GridDataItem(from e.Item) shows that the cell contains no controls. Could somebody please help me on how to maintain the controls when the Insert or Update commands are fired.
Also once this is done I would also like to know, which method to override or event to register to, so that when I call the ExtractValues method on the GridDataItem(from e.Item) object, I get the value from that specific control in the cell that I will decide.
Thanks
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 30 Apr 2011, 06:57 AM
Hello David,
I am not quite sure how you have added Labels to cell in grid. Try the FindControl methos to get the label like below.
C#:
Also refer the following documentation to get the the control and its value in Update/InsertCommand when using 'InPlace'editForms.
Updating values in-place and with edit forms
And please paste your complete code to help more on this.
Thanks,
Princy.
I am not quite sure how you have added Labels to cell in grid. Try the FindControl methos to get the label like below.
C#:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
Label lb = (Label)editItem.FindControl(
"Label1"
);
}
Also refer the following documentation to get the the control and its value in Update/InsertCommand when using 'InPlace'editForms.
Updating values in-place and with edit forms
And please paste your complete code to help more on this.
Thanks,
Princy.
0

Dennis
Top achievements
Rank 1
answered on 03 May 2011, 06:54 AM
Hi,
Here's the code that I've implemented. The problem is that the controls added into the cell are not present when the insert/Update command is fired. The GridEditableItem["UniqueName"].controls.Count is 0.
Here I have extended Telerik.Web.UI.GridEditableColumn
When rendered on the form the two label controls are present in normal as well as in edit mode(InPlace editing). However, on Insert/Update command both controls are lost.
Thanks.
Here's the code that I've implemented. The problem is that the controls added into the cell are not present when the insert/Update command is fired. The GridEditableItem["UniqueName"].controls.Count is 0.
Here I have extended Telerik.Web.UI.GridEditableColumn
public class MyCustomColumn1 : Telerik.Web.UI.GridEditableColumn
{
public
override
void
InitializeCell(System.Web.UI.WebControls.TableCell cell,
int
columnIndex, GridItem inItem)
{
if
(riskRankDataTable ==
null
)
{
getRiskRankDataTable();
}
if
(cell !=
null
)
{
if
(item.IsInEditMode)
{
cell.Controls.Clear();
}
Label lcText =
new
Label();
lcText.Text = textvalue;
//val.ToString();
cell.Controls.Add(lcText);
lcText.ClientIDMode = ClientIDMode.Predictable;
//lcText.ClientID =
Label lcValue =
new
Label();
lcValue.Text = val.ToString();
//textvalue;
cell.Controls.Add(lcValue);
lcValue.ClientIDMode = ClientIDMode.AutoID;
lcValue.Style.Add(
"display"
,
"none"
);
}
base
.InitializeCell(cell, columnIndex, inItem);
}
}
When rendered on the form the two label controls are present in normal as well as in edit mode(InPlace editing). However, on Insert/Update command both controls are lost.
void
RadGrid1_InsertCommand(
object
sender, GridCommandEventArgs e)
{
GridDataItem dataItem =
null
;
if
(e.Item
is
GridDataItem)
{
dataItem = (GridDataItem)e.Item;
}
if
(dataItem !=
null
)
{
if
(dataItem[
"MyCustomColumn1"
].Controls.Count <= 0)
{
//The label controls were not found
}
Dictionary<
string
,
object
> dict =
new
Dictionary<
string
,
object
>();
dataItem.ExtractValues(dict);
}
}
Thanks.
0

Dennis
Top achievements
Rank 1
answered on 04 May 2011, 06:38 AM
Hi,
I would like to know which method to override or event to register to get the value in the ExtractValues method of the GridDataItem in the Insert/Update/Delete commands. I have tried to override the FillValues method of the GridEditableColumn class but it does not get invoked.
Thanks,
I would like to know which method to override or event to register to get the value in the ExtractValues method of the GridDataItem in the Insert/Update/Delete commands. I have tried to override the FillValues method of the GridEditableColumn class but it does not get invoked.
Thanks,
0
Hello David,
To achieve the desired functionality you could try using the custom editors which extend the default editors of the RadGrid columns. On the following online documentation article you could find more information:
http://www.telerik.com/help/aspnet-ajax/grid-custom-editors.html
The other option is to use the GridBoundColumn with the following configuration:
Then into UpdateCommand you could get the values with the following code snippet:
Additionally I am sending you a simple example which demonstrates the described approaches. Please check it out and let me know if it helps you.
Kind regards,
Radoslav
the Telerik team
To achieve the desired functionality you could try using the custom editors which extend the default editors of the RadGrid columns. On the following online documentation article you could find more information:
http://www.telerik.com/help/aspnet-ajax/grid-custom-editors.html
The other option is to use the GridBoundColumn with the following configuration:
GridBoundColumn boundColumn =
new
GridBoundColumn();
...
boundColumn.ReadOnly =
true
;
boundColumn.ForceExtractValue = GridForceExtractValues.Always;
Then into UpdateCommand you could get the values with the following code snippet:
Hashtable newValues =
new
Hashtable();
(a.Item
as
GridDataItem).ExtractValues(newValues);
var field1Value = newValues[
"DataField"
];
Additionally I am sending you a simple example which demonstrates the described approaches. Please check it out and let me know if it helps you.
Kind regards,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Dennis
Top achievements
Rank 1
answered on 07 May 2011, 04:50 AM
Hi,
Thanks for the reply but I had extended the GridEditableColumn class to create my own custom Column. I needed the column to return the required values when I called the ExtractValues method. I had overriden the FillValues method but it did not get Invoked. It turns out that I had to override the ShouldExtractValues method to simply return true.This caused the ExtractValues method to invoke the FillValues method. Anyways thanks for the reply.
Thanks
Thanks for the reply but I had extended the GridEditableColumn class to create my own custom Column. I needed the column to return the required values when I called the ExtractValues method. I had overriden the FillValues method but it did not get Invoked. It turns out that I had to override the ShouldExtractValues method to simply return true.This caused the ExtractValues method to invoke the FillValues method. Anyways thanks for the reply.
Thanks