When using the ultrawebgrid of infragistics netadvantage, you will always encounter problems such as how to select the value of a field of the current row, check the control of the template column, and determine its status. I found related problems on the Internet, and wrote them here.
1. obtain the information of the row selected by ultrawebgrid.
First, set the ultrawebgrid selection status to the row selection mode. Ultrawebgrid1.displaylayout. selecttyperowdefault = Infragistics. webui. ultrawebgrid. selecttype. Single;
then you can obtain the information of the selected row /// the values in the first ultrawebgrid1 column are as follows:
string gridvalue = ultrawebgrid1.displaylayout. selectedrows [ 0 ]. getcellvalue ( This . ultrawebgrid1.columns [ 0 ]). tostring ();
ThisCodeTo obtain the values of a row in a column of any row in ultrawebgrid.//Obtains the value of column 1st of row I.
StringYqbh=Ultrawebgrid1.displaylayout. Rows [I]. getcellvalue (ultrawebgrid1.columns [1]). Tostring ();
2. Set the 0th column of ultrawebgrid as the template column and add the checkbox control to check whether the status is selected. The Code is as follows:
// It can be written anywhere and is a common code.
Infragistics. webui. ultrawebgrid. templatedcolumn tcol =
(Templatedcolumn) ultrawebgrid1.bands [ 0 ]. Columns [ 0 ]; // Template Column
Foreach (Cellitem item In Tcol. cellitems)
{
System. Web. UI. webcontrols. checkbox chkishaveright =
(System. Web. UI. webcontrols. checkbox) item. findcontrol ( " Chbshenhe " );
If (Chkishaveright. Checked = True )
{
//Perform related operations
}
}
Here, we need to consider how to implement cross-row operations on ultrawebgrid. The row values can be calculated and processed according to ultrawebgrid. displaylayout. Pager. pagesize.