We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Store object for the cell


Hi,

I want to store some background value (say object of class) to every cell in the databoundgrid. Is there any way to do it? I tried with control and tag properties but they are showing null after adding it and checking in any other event.

Thanks,
Sandeep

5 Replies

AD Administrator Syncfusion Team November 15, 2006 06:34 AM UTC

Hi Sandeep,

If you want to set a GridStyleInfo.Tag property on a cell specific basis in a DataBoundGrid, then you have to handle Model.QueryCellStyleInfo and set e.style.Tag based on the values passed in through the event arguments.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBGTag_270c4675.zip

Best Regards,
Haneef


SA Sandeep November 15, 2006 08:47 AM UTC


Hi Haneef,
QueryCellStyleInfo will get execute at the time of binding. Its OK. But now I want to add the object for the cell at some other position like after clicking the button I want to add background object to particular cell by using its rowindex and colindex. So what exactly I would require to do for it.

Thanks,
Sandeep


AD Administrator Syncfusion Team November 15, 2006 10:22 AM UTC

Hi Sandeep,

In QueryCellStyleInfo, you should have some collection (or something) that holds the object that you assign to e.Style.Tag. When you want to modify the Tag, you need to set the object value in this collection (or something) with RowIndex and ColIndex as the Key. Please refer to the attached sample for implementation and let us know if you are looking something different.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBGTaghash_87e4997c.zip

Best Regards,
Haneef


SA Sandeep November 16, 2006 06:12 AM UTC


Hi Haneef,

Thanks for your sample.
But I want little different thing.

I have dropped the idea of storing the object at the back of the cell. I want now to store only one particular string at the back of cell (front text of cell will be different.). I dont want to use the event like QueryCellStyleInfo which require Hashtable or any other collection as a middle.
Is there any way to do store string at back of cell at particular position. Please let me know if it is possible.

Thanks,
Sandeep


AD Administrator Syncfusion Team November 16, 2006 06:50 AM UTC

Hi Sandeep,

It is not possible to store the cell style properties other than handling the events(Model.QueryCellInfo) for a DataBoundGrid. If you want to change the display text of the cells in a grid, you can handle the DrawCellDisplayText event and set the e.DisplayText to some new value to want to display. Use the e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.

private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellIdentity.ColIndex == 1 && e.Style.CellIdentity.RowIndex > 0 && e.DisplayText != null && e.DisplayText != string.Empty )
{
e.DisplayText = "JustForDisplay" ;
}
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon