Hi All,
I have spent hours and days to get post back for chekbox inside a ultrawebgrid (Using Sharepoint Webpart) using updatecell event.But every time i click checkbox it making duplicate columns with no data.
No idea really what the hell is going on.
I found some wwhere that there is no way of firing an event for manually added checbox inside ultrawebgrid.
Please help me.
Million Thanks in advance.
Hello,
Your scenario is not very clear for me but I 'd suggest you take a look at the following link :
Using ItemCommand Event to Access Cell Item . The demonstrated approach is the recommended way to raise an event from control which is placed inside of Template Column of the grid.
Hi Rado,
Thanks for your response. that is little helpful.
Can you help me how to add templated checkbox column to ultrawebgrid in Sharepoint Webpart.Since webpart has no design interface , we need to do it in code behind.
Thanks.
The general way to create a Template is as follows:
1. Create class that implement ITemplate interface like this:
//Create a template
private class CustomItemTemplate : ITemplate
{
//Here you can put whatever control you want.
public void InstantiateIn(Control container)
CheckBox checkBox = new CheckBox();
checkBox.Checked = true;
container.Controls.Add(checkBox);
}
2. Create a template column then instantiate your custom template and add the template to the Column collection of the grid like this:
//Create a template column
void createTemplateColumn() {
//Create a template column.
TemplatedColumn col1 = new TemplatedColumn(true) ;
col1.Header.Caption = "Template column";
col1.Key = "r1";
//Assign the template control to the template column.
col1.CellTemplate = new CustomItemTemplate();
UltraWebGrid1.Columns.Add(col1);
hi Rado,
Thank you very much for your response.
I am getting error at ITemplate (error: Must implement sub instantiatein (container as control) for interfaace)
I've put together a small sample in order to demonstrate how to create a template column in code-behind.
Please see the sample.
Le me know if you still have issue with.
Attaching the sample.