Selecting row from grid and performing particular operation for a particular row using asp.net , mvc and web-api.
![]() |
| Selecting a particular grid row that satisfies a particular condition and with that row perform different kind of operations |
Purpose: selecting a particular grid row that satisfies a particular condition and with that row perform different kind of operations. We will perform operation here using of asp.net (c#) programming.
Uses : this
type of functionality keeps very important when we need to perform operation for a particular rows that satisfies
a particular conditions. For example we have to show grid from the table with
condition that every row with “Y” flag will display in green colour.
Initially it really looks tough task but if we do this
functionality step by step ,it becomes quite easy so we do not have to be
feared just follow the steps
For satisfying this condition we will first bind the table
data with grid and then find all the rows having flag “Y” and set it to green
using external css class.
ASP.NET(C#) :
protected void gvProduts_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
if ((e.Item as GridDataItem)["DoNotCallPhone"].Text == "Y")
{
(e.Item as GridDataItem).CssClass
= "rgGreenRow";
}
}
}
Description: here we are selecting one by one every
row from grid product and setting there colour from normal to green . ’GridDataItem’ is a collection of
data for a particular row.
Since item data bound provide us last opportunity to access
the data item before it displayed on the client so it is a better way to
satisfy grid data display conditions in item data bound.

Comments
Post a Comment