简体   繁体   中英

'GridView' does not contain definition for 'RowIndex' and no extension method 'RowIndex' accepting first argument of type 'xGridView' could be found

I am using MS Visual Studio 2010 and I imported this aspx which I believe was from an older version Framework.

protected void selectedbutton_Click(object sender, EventArgs e)
{
    string PKname = ""; int k = 0;
    foreach (GridView row in this.selectMedGridView.Rows)
    {

        CheckBox cbox = (CheckBox)row.FindControl("selrecord");
        if (cbox.Checked)
        {
            PKname += "ID=" + this.selectMedGridView.DataKeys[row.RowIndex].Value.ToString().Trim() + "&";
        }
        k++;
    }
    Response.Redirect("view_selected_med_records.aspx?" + PKname);

}

I received this Error and it seems to have something to do with the word RowIndex . I assume this syntax does not exist in the newer version.

However I have no idea what is the new syntax. Can anyone help me?

迭代变量的类型需要为GridViewRow而不是GridView

foreach (GridViewRow row in this.selectMedGridView.Rows)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question GridView does not contain a definition for 'Columns' and no extension method 'Columns' accepting a first argument of type 'GridView' could be found 'Type' does not contain a definition for 'Assembly' and no extension method 'Assembly' accepting first argument of type 'Type' could be found 'Object' does not contain a definition for 'Rows' and no extension method 'Rows' accepting a first argument of type 'object' could be found 'IEnumerable<>' does not contain a definition for '' and no extension method '' accepting a first argument of type 'IEnumerable<>' could be found 'IEnumerable<>' does not contain a definition for '', no extension method '' accepting a first argument of type 'IEnumerable<>' could be found Does not contain a definition for and no extension method accepting a first argument of type could be found ServiceCollection does not contain a definition for AddScoped and no accessible extension method accepting a first argument of type could be found object' does not contain a definition for 'Save' and no extension method 'Save' accepting a first argument of type 'object' could be found 'object' does not contain a definition for 'NewRow' and no extension method 'NewRow' accepting a first argument of type 'object' could be found ''does not contain a definition for 'Session' and no extension method '' accepting a first argument of type 'object' could be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM