I tried to submit this as a support ticket but it timed out so am posting here
----------------------------------------------------------------------------------------------------------
I can add validators to built in columns with no problem using the following code:
protected void rgData_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
if (e.Item.OwnerTableView.DataMember == "Download")
{
GridTemplateColumnEditor edFile = (GridTemplateColumnEditor)item.EditManager.GetColumnEditor("DocumentFile");
GridTextBoxColumnEditor edDescription = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("Description");
edDescription.TextBoxControl.ID = "txtDescription";
edDescription.TextBoxControl.Width = Unit.Pixel(350);
However this does not seem to work with template columns. One of my template columns contains a FileUpload control. Above you can see where I try and reference it (edFile). But when I try to access the control using
((FileUpload)edFile.FindControl("fuFile")).Width = Unit.Pixel(350);
or
((FileUpload)edFile.Controls[0]).Width = Unit.Pixel(350);
I get a null reference. I was hoping I could keep all this code in the same place (ItemCreated). But do template columns need to be handled differently? Thanks.
----------------------------------------------------------------------------------------------------------
I can add validators to built in columns with no problem using the following code:
protected void rgData_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
if (e.Item.OwnerTableView.DataMember == "Download")
{
GridTemplateColumnEditor edFile = (GridTemplateColumnEditor)item.EditManager.GetColumnEditor("DocumentFile");
GridTextBoxColumnEditor edDescription = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("Description");
edDescription.TextBoxControl.ID = "txtDescription";
edDescription.TextBoxControl.Width = Unit.Pixel(350);
However this does not seem to work with template columns. One of my template columns contains a FileUpload control. Above you can see where I try and reference it (edFile). But when I try to access the control using
((FileUpload)edFile.FindControl("fuFile")).Width = Unit.Pixel(350);
or
((FileUpload)edFile.Controls[0]).Width = Unit.Pixel(350);
I get a null reference. I was hoping I could keep all this code in the same place (ItemCreated). But do template columns need to be handled differently? Thanks.