Nevermind. I moved the creating of the TemplateField to Init and that fixed both issues.
Mark
I have successfully added a TemplateDataField to my WebDataGrid but now I have two problems.
1. Although I set the CommandName and CommandArgument I cannot get the ItemCommand event to fire. I get a postbask, but the ItemCommand event does not fire. Here is my code:
Sub BuildLinks(ByVal ctrl As Control) Dim access As IParserAccessor = ctrl Dim link As New LinkButton link.Text = "View" link.CommandArgument = "1" link.ID = "linkView" link.CommandName = "idEmployee" access.AddParsedSubObject(link)End Sub
//Here is the code to add the TemplateAddHandler ProjectedGrid.ItemCommand, AddressOf ProjectedGrid_ItemCommandDim templateField As New TemplateDataFieldtemplateField.Header.Text = "Action"templateField.Key = "KEY_ACTION"Dim TemplateItem As New CompiledBindableTemplateBuilder(New BuildTemplateMethod(AddressOf BuildLinks), Nothing)templateField.ItemTemplate = TemplateItemProjectedGrid.Columns.Add(templateField)
//In my InitializeRow event I haveDim actionLink As LinkButton = e.Row.Items.FindItemByKey("KEY_ACTION").FindControl("linkView")actionLink.CommandArgument = idEmployee
2. After the postback, the LinkButton is gone. The column is still there but the LinkButton is not.
Thoughts?
Hi,
Suppose you have registered InitializeRow event handler you will be able to get the value of particular control inside the template column like this :
this.WebDataGrid1.InitializeRow += new InitializeRowEventHandler(WebDataGrid1_InitializeRow);
void WebDataGrid1_InitializeRow(object sender, RowEventArgs e)
{
LinkButton lb = (LinkButton)e.Row.Items.FindItemByKey("TemplateColumn").FindControl("LinkButton1");
}
Hi Dinesh,
Thanks. I have created the checkbox template column successfully.
How shall i trigger an event for this checkbox
or
how shall i get this checked value from code-behind?
I am googling this for past 2 weeks ... could you provide a solution as soon as possible.
How code if need bound data with TemplateDataField dynamic
Thank you
m