I have a similar example, but for some reason the image button command event I am creating does not fire on the initial page load, it causes a postback, and then after postback it fires correctly. Any help??
<igmisc:WebAsyncRefreshPanel LinkedRefreshControlID="xxx" ID="WebAsyncRefreshPanelControl" runat="server" Width="100%">
<asp:Label ID="lblErr1" runat="server" CssClass="error" />
<center>
<table cellpadding="2" cellspacing="1" border="0" width="725px">
<tr valign="top">
<td>
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" OnClickCellButton="UltraWebGrid1_OnClickCellButton">
<DisplayLayout Name="UltraWebGrid1" AllowSortingDefault="yes" HeaderClickActionDefault="SortSingle"
RowSelectorsDefault="No" SelectTypeRowDefault="Single" SelectTypeCellDefault="Single"
StationaryMargins="Header" TableLayout="Fixed" Version="4.00" />
</igtbl:UltraWebGrid>
</td>
</tr>
</table>
</center>
<igtxt:WebDateTimeEdit ID="WebDateTimeEdit1" runat="server" DataMode="EditModeText" />
<igcmbo:WebCombo ID="cmbReportSchFrequency" runat="server" Version="4.00" DataValueField="ID" DataTextField="Name" DisplayValue="Name" />
<igcmbo:WebCombo ID="cmbReportDay" runat="server" Version="4.00" DataValueField="ID" DataTextField="Name" DisplayValue="Name" />
private clsSecurity _clsSecurity = null;
protected PlaceHolderTemplate pt = null;
private bool HasUserAndPass = true;
{
bool bRedirect = false;
try
}
else
this.lblErr1.Visible = true;
Common.ZLog(System.Web.HttpContext.Current, ErrorMsg, ex);
InitializeComponent();
TemplatedColumn tc = new TemplatedColumn(true);
tc.SortIndicator = SortIndicator.Disabled;
e.Layout.Bands[0].Columns.Add(tc);
pt.Grid1 = UltraWebGrid1;
tc.CellTemplate = pt;
e.Layout.Bands[0].Columns.FromKey("Delete").Move(1);
e.Layout.StationaryMargins = StationaryMargins.Header;
e.Layout.RowHeightDefault = new Unit("27px");
e.Layout.Bands[0].Columns.FromKey("xxx").Hidden = true;
e.Layout.Bands[0].Columns.FromKey("Delete").Header.Caption = "Del";
e.Layout.Bands[0].Columns.FromKey("xxx").Header.Caption = "Created";
e.Layout.Bands[0].Columns.FromKey("xxx").Header.Caption = "Day";
e.Layout.Bands[0].Columns.FromKey("xxx").Header.Caption = "Time";
e.Layout.Bands[0].Columns.FromKey("xxx").Width = new Unit("25px");
e.Layout.Bands[0].Columns.FromKey("xxx").Width = new Unit("100px");
e.Layout.Bands[0].Columns.FromKey("xxx").Width = new Unit("80px");
public class PlaceHolderTemplate : ITemplate
ImageButton ib = new ImageButton();
ib.CommandArgument = ci.Cell.Row.Index.ToString();
ib.Attributes.Add("onclick", "return confirm ('Delete this record?');");
ci.Controls.Add(ib);
UltraGridRow currentRow = Grid1.Rows[Val];
/// <summary>
/// This method ensures that the delete button is present after page postbacks.
/// </summary>
/// <param name="sender"></param>
iTimeFormat = _clsSecurity.TimeFormat;
string sFormat = iTimeFormat == Common.TIME_FORMAT_STANDARD ? "hh:mm tt" : "HH:mm";
LoadGrid();
UltraWebGrid1.DataSource = ds;
UltraWebGrid1.DataBind();
UltraWebGrid1.Columns.FromKey("Edit").Move(0);
UltraWebGrid1.Columns.FromKey("Edit").Type = ColumnType.Button;
UltraWebGrid1.Columns.FromKey("Edit").CellButtonDisplay = CellButtonDisplay.OnMouseEnter;
UltraWebGrid1.Columns.FromKey("Edit").CellButtonStyle.BorderWidth = new Unit("0px");
UltraWebGrid1.Columns.FromKey("Edit").Header.Caption = "Edt";
this.UltraWebGrid1.Bands[0].Columns.FromKey("xxx").EditorControlID = WebDateTimeEdit1.UniqueID;
this.UltraWebGrid1.Bands[0].Columns.FromKey("xxx").EditorControlID = cmbReportDay.UniqueID;
this.UltraWebGrid1.Bands[0].Columns.FromKey("xxx").DataType = "System.Int32";
this.UltraWebGrid1.Bands[0].Columns.FromKey("xxx").EditorControlID = cmbReportSchFrequency.UniqueID;
/// bind dataset to the web combo.
/// <param name="WC"> the web combo to bind</param>
WC.DataSource = dt;
WC.DataBind();
m.DisplayErrorMsg(ErrorMsg + ex.Message);
break;
//rs.Delete(sID);
Issues like that are typically related to ASP.NET page life-cycle - e.g. at the time of adding the dynamic content it is already too late in order to add it to the control tree in such a way that it operates as expected. The WARP instance can also affect that.
I have a couple of suggestions:
1. Try using different events for adding the dynamic templated column to the Columns collection. Typically columns are added in the InitializeLayout event of the grid. You can also try Page.OnInit.
2. Remove the WARP panel to see if this makes a difference.