I’m new in asp.net and trying to pull values from Sqlserver into a listView (asp.net). In codebehind, I want to iterate through all rows and pull cell values for columnX if a checkbox in rowY is checked. I’m getting a compilation error on the following code but cannot figure out the problem. I can get cell values from GridView but not ListView.
while (i < WOListView.Items.Count) {
CheckBox cbCell = (CheckBox)WOListView.Items[i].FindControl("CheckBox1");
if (cbCell.Checked) {
if (WOListView.Items[i].SubItems[1].Text == "WO") {
do stuff...
}
}
}
And the resulting error code:
CS1061: ‘System.Web.UI.WebControls.ListViewDataItem’ does not contain a definition for ‘SubItems’ and no extension method ‘SubItems’ accepting a first argument of type ‘System.Web.UI.WebControls.ListViewDataItem’ could be found
Is there a different way of doing this? Is SubItems not supported?
there is no subitems in listview. If I am not wrong, you are looking for a control inside listview