Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
865
How to add button column, checkbox column to webdata grid from c# code
posted

Hi Team,

I am working in a migration project where code is getting migrated from Infragistics 2011 to 2014. Hence UltraWebGrid is getting converted to WebDatagrid.

Sharing the code snippet here where on InitializeLayout of a grid, columns are getting added via c# code..

So in InitializeLayout following line is getting called:

uwGridShutDown.Columns.Add(...) and based on the nature of desired column, the one of below function gets called..

How can I do this in webdatagrid where I can add any type of available controls from c#.. Please refer the code below..

Regards

Varun

protected Infragistics.WebUI.UltraWebGrid.UltraGridColumn AddColumn(string baseColumnName, string caption, HorizontalAlign align, bool hidden, bool allowUpdate, bool isBound, string format,double width)
{
Infragistics.WebUI.UltraWebGrid.UltraGridColumn ugColumn = new Infragistics.WebUI.UltraWebGrid.UltraGridColumn();
ugColumn.BaseColumnName = baseColumnName;
ugColumn.Header.Caption = caption;
ugColumn.CellStyle.HorizontalAlign = align;
ugColumn.Hidden = hidden;
ugColumn.Key = caption;
ugColumn.AllowUpdate = (allowUpdate) ? Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes : Infragistics.WebUI.UltraWebGrid.AllowUpdate.No;
ugColumn.IsBound = isBound;
if (width > 0)
ugColumn.Width = Unit.Parse(width.ToString()+"em");
if (!allowUpdate)
ugColumn.CellStyle.BackColor = System.Drawing.Color.WhiteSmoke;

if (format != "")
ugColumn.Format = format;

return ugColumn;
}
protected Infragistics.WebUI.UltraWebGrid.UltraGridColumn AddCheckBoxColumn(string baseColumnName, string caption, HorizontalAlign align, bool hidden, bool allowUpdate, bool isBound, string format, double width)
{
Infragistics.WebUI.UltraWebGrid.UltraGridColumn ugColumn = new Infragistics.WebUI.UltraWebGrid.UltraGridColumn();

ugColumn.BaseColumnName = baseColumnName;
ugColumn.Header.Caption = caption;
ugColumn.CellStyle.HorizontalAlign = align;
ugColumn.Hidden = hidden;
ugColumn.Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox;
ugColumn.Key = caption;
ugColumn.AllowUpdate = (allowUpdate) ? Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes : Infragistics.WebUI.UltraWebGrid.AllowUpdate.No;
ugColumn.IsBound = isBound;
if (width > 0)
ugColumn.Width = Unit.Parse(width.ToString() + "em");
if (!allowUpdate)
ugColumn.CellStyle.BackColor = System.Drawing.Color.WhiteSmoke;

if (format != "")
ugColumn.Format = format;

return ugColumn;
}

protected Infragistics.WebUI.UltraWebGrid.UltraGridColumn AddButtonColumn(string baseColumnName, string caption, HorizontalAlign align, bool hidden, bool allowUpdate, bool isBound, string format, double width)
{
Infragistics.WebUI.UltraWebGrid.UltraGridColumn ugColumn = new Infragistics.WebUI.UltraWebGrid.UltraGridColumn();

ugColumn.BaseColumnName = baseColumnName;
ugColumn.Header.Caption = caption;
ugColumn.CellStyle.HorizontalAlign = align;
ugColumn.Hidden = hidden;
ugColumn.Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Button;
ugColumn.Key = caption;
ugColumn.AllowUpdate = (allowUpdate) ? Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes : Infragistics.WebUI.UltraWebGrid.AllowUpdate.No;
ugColumn.IsBound = isBound;
if (width > 0)
ugColumn.Width = Unit.Parse(width.ToString() + "em");
if (!allowUpdate)
ugColumn.CellStyle.BackColor = System.Drawing.Color.WhiteSmoke;

if (format != "")
ugColumn.Format = format;

return ugColumn;
}

protected Infragistics.WebUI.UltraWebGrid.UltraGridColumn AddWebComboColumn(string baseColumnName, string caption, HorizontalAlign align, bool hidden, bool allowUpdate, bool isBound, string format, string editorControlID, double width)
{
Infragistics.WebUI.UltraWebGrid.UltraGridColumn ugColumn = new Infragistics.WebUI.UltraWebGrid.UltraGridColumn();

ugColumn.BaseColumnName = baseColumnName;
ugColumn.Header.Caption = caption;
ugColumn.CellStyle.HorizontalAlign = align;
ugColumn.Hidden = hidden;
ugColumn.Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom;
ugColumn.EditorControlID = editorControlID;
ugColumn.ValueList.DisplayStyle = Infragistics.WebUI.UltraWebGrid.ValueListDisplayStyle.DisplayText;
ugColumn.Key = caption;
ugColumn.AllowUpdate = (allowUpdate) ? Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes : Infragistics.WebUI.UltraWebGrid.AllowUpdate.No;
ugColumn.IsBound = isBound;
if (width > 0)
ugColumn.Width = Unit.Percentage(width);
if (!allowUpdate)
ugColumn.CellStyle.BackColor = System.Drawing.Color.WhiteSmoke;

if (format != "")
ugColumn.Format = format;

return ugColumn;
}

Parents
No Data
Reply Children