Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

How to modify a column value during the OnBatchEditCommand event

$
0
0

Hi,

I'm sure that answer already exists, but I searched through the forum and couldn't find a solution. 

I have a batch mode grid that invokes a web service, during the OnBatchEditCommand event, when saving data.  The service performs the update and returns a DataTable which identifies the results of the insert/update/delete actions.  The results include a status, error message and datetime value for every row that was processed. 

To help the user, we have a GridTemplateColumn (seen below), containing an image used to depict the results.  If the status is "Ok", we want to display a green check mark.  If the status is "Error", we want to display a red 'X'.  As you can imagine, in order for the user to correct the error, we don't want to overwrite any data that they may have entered.  As such, we don't want to reset the grids DataSource.  (Note that we do validate the data prior to calling the web service, but need to be cautious.)

<telerik:GridTemplateColumn ItemStyle-Wrap="false" DataField="STATUS" FilterControlAltText="Filter STATUS column" HeaderText="Row Status" SortExpression="STATUS" UniqueName="STATUS">
<ItemTemplate>
<asp:Image runat="server" ID="RowStatus" ImageUrl='<%#"/_layouts/15/images/projname/MUE_" + Eval("STATUS") + ".png"%>' />
</ItemTemplate>
</telerik:GridTemplateColumn>

So, after obtaining the returned DataTable, we would like to loop through the grid's rows, setting the value of the GridTemplateColumn to the value provided in the DataTable (either "Ok" or "Error").  Doing so, will allow us to display the MUE_Ok.png or MUE_Error.png image.  Obviously, we're open to other solutions that meet our user's requirements.  Note that the initial call to retrieve data, performed during the NeedDataSource event, returns a DataTable that currently includes an "Ok" value (along with all of the other data values) for each row.  As such, each row initially shows the green check mark. 

 Thanks.


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>