I want to put some value in the ultraWebGrid. This is my code:
uwg = new UltraWebGrid();
UltraGridRow ugRow = new UltraGridRow(); uwg.Rows.Add(ugRow);
UltraGridCell ugCell = new UltraGridCell(); uwg.Rows[Convert.ToInt32(rowTest["DTC01"])].Cells.Add(ugCell); uwg.Rows[Convert.ToInt32(rowTest["DTC01"])].Cells[Convert.ToInt32(rowTest["DTC02"])].Value = "allo";wb.ContentPane.Controls.Add(uwg);
For me, I think this code can display "allo". I receive "no data can be display"
Why? and I want the text "allo" appear like a hyperLinkButton
Anyway Im lost, any help can be good.
Gabriel Deschênes
Define columns to add to your grid first. Thus, when you add a row to the grid, it will get cells defined to match the column definitions - you don't need to create cell objects directly.
I also recommend a different approahc to creating both your rows and your columns, which will ensure that they'll be stored in ViewState.
using Infragistics.WebUI.UltraWebGrid;...UltraGridColumn ugCol;...ugCol = new UltraGridColumn(true); // Create the column and ensure it is stored in ViewState// Set other properties on the column here, such as its Key, its DataType, and its Header.Captionuwg.Columns.Add(ugCol);...UltraGridRow ugRow;...ugRow = new UltraGridRow(true); // Create the row and ensure it is stored in ViewStateuwg.Rows.Add(ugRow); // This adds the row to the grid, and implicitly creates its cells// uwg.Cells.FromKey("MyColumn").Value = "allo";ugRow.Cells.FromKey("MyColumn").Value = "allo"; // Replace "MyColumn" with the Key property of the corresponding column...wb.ContentPane.Controls.Add (uwg);
EDIT: Corrected a major typo in my original post.
I did your code.... but I have some error at this line:
uwg.Cells.FromKey("1").Value = "allo";
I receive this message:
Error 3 'Infragistics.WebUI.UltraWebGrid.UltraWebGrid' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'Infragistics.WebUI.UltraWebGrid.UltraWebGrid' could be found (are you missing a using directive or an assembly reference?)
Plus, can I put the string "allo" like a hyperLinkButton
Thanks you
That was a typo in my original post. I've edited my previous post to provide the correct line of code:
ugRow.Cells.FromKey("MyColumn").Value = "allo"; // Replace "MyColumn" with the Key property of the corresponding column
The "Cells" collection belongs to the row object, not to the grid itself. My apologies for the confusion.
You also need to make certain that you've created a column object whose Key property is set to "1" for the FromKey() method to work.
Hi,
I try your code since 4-5 days and I always get the same error. I will show you my complete code to create ultraWebGrid wtih columns and rows.
public partial class _Default : System.Web.UI.Page{
private UltraWebGrid uwg = new UltraWebGrid(); private UltraGridRow ugRow = new UltraGridRow(); private UltraGridColumn ugCol = new UltraGridColumn();
protected void Page_Load(object sender, EventArgs e) {
uwg = new UltraWebGrid(); uwg.ID = "BONBON"; TextBox1.Text = Convert.ToString(ugCol); ugCol = new UltraGridColumn(true); ugCol.Key = "1"; ugCol.Header.Caption = "+++"; **** uwg.Columns.Add(ugCol); ***** (but at this line i receive a NullReferenceException) ugRow = new UltraGridRow(true); uwg.Rows.Add(ugRow); ugRow.Cells.FromKey("1").Value = "ping"; wb.ContentPane.Controls.Add(uwg);
}
I'm lost
thanks for the future help
Gabriel,
Try this:
public partial class _Default : System.Web.UI.Page { private UltraWebGrid uwg;
protected void Page_Init(object sender, EventArgs e) { uwg = new UltraWebGrid();
HtmlForm ctlForm1; ctlForm1 = (HtmlForm)this.FindControl("Form1");
if (ctlForm1 != null) { ctlForm1.Controls.Add(uwg); } }
private UltraGridRow ugRow; private UltraGridColumn ugCol;
protected void Page_Load(object sender, EventArgs e) { uwg.ID = "BONBON"; ugCol = new UltraGridColumn(true); ugCol.Key = "1"; ugCol.Header.Caption = "+++"; uwg.Columns.Add(ugCol); ugRow = new UltraGridRow(true); uwg.Rows.Add(ugRow); ugRow.Cells.FromKey("1").Value = "allo"; TextBox1.Text = Convert.ToString(ugRow.Cells.FromKey("1").Value); }}
Let me know how it goes.
Bonne chance!
Michael
HeyHey!!
it woks perfectly
Merci beaucoup!