不可调用的成员'System.Web.UI.WebControls.GridView.Rows'不能像方法一样使用。 [英] Non-invocable member 'System.Web.UI.WebControls.GridView.Rows' cannot be used like a method.
本文介绍了不可调用的成员'System.Web.UI.WebControls.GridView.Rows'不能像方法一样使用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用gridview,它想要读取行内的数据。但我收到上述错误错误1非可调用成员'System.Web.UI.WebControls.GridView.Rows'不能像方法一样使用。
I am using a gridview which is suppose to read the data inside the rows. But I am getting the above error Error 1 Non-invocable member 'System.Web.UI.WebControls.GridView.Rows' cannot be used like a method.
protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Int32 index = GridView1.SelectedIndex;
lblrep.Text = GridView1.Rows(index).Cells(2).Text;
btndownload.Enabled = true;
}
错误出现在'Rows'一词
the error appears in the word 'Rows'
推荐答案
在C#中,()表示调用函数,[]表示按索引获取。您的行
是通过索引提供对每个raw的访问权限的属性,因此请使用[]。
-SA
In C#, "()" means calling a function, "[]" means "get by index". YourRows
is the property to provide access to each raw by index, so use "[]".
—SA
protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Int32 index = GridView1.SelectedIndex;
lblrep.Text = GridView1.Rows[index].Cells[2].Text;
btndownload.Enabled = true;
}
您正在使用带有这些()的数组而不是这些[] 。
()for VB
[] for C#
You are using an array with these ( ) instead of these [ ].
() for VB
[] for C#
这篇关于不可调用的成员'System.Web.UI.WebControls.GridView.Rows'不能像方法一样使用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文