I am using UltrawebGrid and binding with a datasource in codebehind. I want to bind the ultrawebgrid columns based on the datasource values and also want to change the colour of that cell. Please advice how to proceed.
Hi MPF_COGNIZANT,
Thank you for posting in the community.
In order to define the datasource field used for a column in UltraWebGrid, you may set the BaseColumnName property. For instance:
UltraWebGrid1.Columns[0].BaseColumnName = "ID"; UltraWebGrid1.DisplayLayout.AutoGenerateColumns = false; UltraWebGrid1.DataSource = populateGrid(); UltraWebGrid1.DataBind();
The base column name can be dynamically/conditionally changed in order to implement your requirement. Styling individual cells may be done in the InitializeRow handler by accessing the style of the particular cell:
e.Row.Cells[0].Style.ForeColor = System.Drawing.Color.Green;
Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html
Additional samples demonstrating the features of these grids can be found at:http://samples.infragistics.com/aspnet/
Hope this helps.
Thank you for your response.
I would like assign Ultragrid column data based on dataset values. Not directly assigning datset to ultragrid. i did that based on below script.
dtgtable.DisplayLayout.Rows(iCounter).Cells(0).Value .
But in this first i need to initialise grid with a dataset. Otherwise it is throwing object reference exception.
My second question is that i would like change the color of the control in the grid cell ( checkbox) dynamically based on the dataset values.Please advice the same.
Am thakful you for your quick reply.
Regarding changing color of the control in the grid am creating dynamic columns. And not using any template . Check the same below.
dtgCOAEmailLog.Columns(0).Type =
ColumnType.CheckBox
dtgCOAEmailLog.Columns(0).AllowUpdate =
AllowUpdate.No
dtgCOAEmailLog.Columns(0).Width = Unit.Pixel(70) dtgCOAEmailLog.Columns(0).HeaderText = "text1"
dtgCOAEmailLog.Columns(0).Width =
Unit.Pixel(70)
dtgCOAEmailLog.Columns(0).HeaderText = "text1"
dtgCOAEmailLog.Columns(0).HeaderText =
"text1"
Please let me know how to proceed in this case.
Thank you for your reply.
I am attaching a sample for you demonstrating how the style of the whole checkbox column may be set, and how single cells from that column may be individually styled. Please note that when using columns of type "Checkbox", the input elements themselves do not exist and are not available on the server. Therefore if you need to style the checkboxes themselves differently, I would suggest that you consider using a templated column.
Feel free to contact me if you have any questions.
Please do not hesitate to contact me if you are experiencing any issues regarding this scenario.
Am very grateful for your work.
I can able to set the backcolor. But my requirement is forecolor. In other words i want check box check color. When i set forecolor of the column it is not reflecting. And am not able to find the control because am not using any template for grid. Is there any way or only option to use template?
If your requirement is to style the "tickmark" of a checkbox, this can be achieved for a checkbox by using CSS and some clientside scripting. A detailed guide for achieving that can be found at:
http://www.thecssninja.com/css/custom-inputs-using-css
As the checkboxes of a UltraWebGrid checkbox column are not available on the server, in this scenario it may be more practical to use a templated column.
Please feel free to contact me if you have any questions.
Thanks for your valuble infomation.
Please do not hesitate to contact me if I can be of assistance.