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 currently selected row. // the value of the first column of ultrawebgrid1 is as follows:
String gridvalue = ultrawebgrid1.displaylayout. selectedrows [0]. getcellvalue (this. ultrawebgrid1.columns [0]). tostring ();
Inspired by this code, you can obtain the value of a row in a column of any row in ultrawebgrid // obtain the value of column 1st in row I.
String yqbh = 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.