Hello,
I'm having an issue with the grid's grdGrid_InitializeRow event. I have added 2 columns in which there are images. So while the grid initializes the row, it becomes very very slow to retrieve the data on page. I just want to ask, how to increase the grid performance.
If I comment out the grdGrid_InitializeRow function, (the images in the 2 columns are not displayed) then then the grid is displayed pretty fast.
Is there any way to add an image in each of the cell of column without making the grid performance slow?
Please help.
Thank You
Hi AmrutaDeshpande,
Obviously I am not aware what type of columns you are trying to display an image into, however I can suggest a straightforward approach using an UnboundField to display images.
For instance, in order to show two images in alternating rows in the said unbound field, you could use:
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e) { if (e.Row.Index % 2 == 0) { e.Row.Items[3].Value = "<img src=\"test.bmp\"></img>"; } else { e.Row.Items[3].Value = "<img src=\"test1.bmp\"></img>"; }}
{ if (e.Row.Index % 2 == 0) { e.Row.Items[3].Value = "<img src=\"test.bmp\"></img>"; } else { e.Row.Items[3].Value = "<img src=\"test1.bmp\"></img>"; }}
In order for this to work the HtmlEncode property of the UnboundField has to be set to False.
Some alternative approaches for displaying images in the WebDataGrid can be found in the following sample:
http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Style/Custom-CSS/Default.aspx?cn=data-grid&sid=bcf4fb6c-e048-4935-8f4e-736a74e5c2f3
Please let me know if this helps.
Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Hi,
Thanks for the update. I'm doing more over similar to the solution you've provided. Here is my code below.
Protected Sub grdGrid_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles grdGrid.InitializeRow
Dim sEmpId As String
sEmpId = "imgFlag" & e.Row.Cells.FromKey("EMPID").Value '//Some conditions
e.Row.Cells.FromKey("COMMENT").Text = "<input type='image' id=" & sEmpId & " src='../../Images/edit-01.gif' onclick='Open();' title='image'>"
'//some other code
end if
But the problem is, if I comment out the entire initialize_row event, my grid becomes faster in execution. The column "COMMENT" I'm retrieving from database with NULL values so that In row_initialize function I can add image in each of the cell of that column.
Please help me with this. How to execute the grid faster apart from this?
Thanks
This seems to be a UltraWebGrid question. In the future please submit your UltraWebGrid related questions in the respective forum:
http://forums.infragistics.com/forums/61.aspx
In order to improve the performance of the grid, I would suggest using XML Load On Demand. More information on how to setup LoadOnDemand of the grid can be found at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebGrid_Using_XML_Load_On_Demand.html
Additional tips regarding the grid's performance can be found at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebGrid_Performance.html
If I am understanding correctly, you are querying your DataBase separately for each row in order to determine which image is to be used. If this is the case I would suggest using a global query to save time from the trips to the database.
Please contact me if you have any questions.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://es.infragistics.com/support
Thanks for the update.It seems quite helpful.
I'll try using XML and I think that should work. But also that I'm data binding the grid, so even in case of XML I'll have to convert the DB result to data set. Would doing that increase the performance?
Currently I'm using UltraWebGrid Version=10.3.20103.2134
I'm not actually having a DB trip for each row, but via data set. There is only one DB trip before page load. Regarding using global query, could you provide me with the sample code for that?
Using Load on Demand should in any case improve the performance regardless of the data source used.
Regarding using a global search, I meant that in the sense of not making separate trips to the DB for each row so your data set implementation should work fine in this case.
Please contact me if I can be of further assistance.
Please contact me if you have further questions.