更新时间:2022-04-12 22:18:07
您说的主要内容是确定第二个GridView在最少索引+1行?
如果您主要在GridView2里面有一些行,答案是,但是我想我的问题是,当我在下面的新代码中执行此操作时,如何在GridView1内的GridView2处定义新索引,问题就解决了,但是代码不起作用网页重新加载,但没有区别:
what you main when you say are you sure that this second GridView has at least index+1 rows?
if you main if the GridView2 have some rows inside it the answer yes but I thing my problem is how I can define new index for GridView2 where it is inside GridView1 when I do this the below new code the Problem is finish but the code not work the web page reload but No difference happen:
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "publish1")
{
int index1 = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "publish")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
GridView grd = new GridView();
grd = ((GridView)GridView1.Rows[index].FindControl("GridView2"));
int flsid = Convert.ToInt32(((Label)grd.Rows[index1].FindControl("lblflsid")).Text);
bool pub = ((CheckBox)grd.Rows[index1].FindControl("chkpub1")).Checked;
你能帮我吗
can you help me
先生. csharpbd2如何在此代码中尝试使用0替换索引变量
mr. csharpbd2 how I can try use 0 replace index variable in this code
int flsid = Convert.ToInt32(((Label)grd.Rows[index].FindControl("lblflsid")).Text);
很抱歉,但我是编程的初学者.
I''m sorry but I''m Beginner in programming
您似乎正在使用index
作为两个不同集合的索引:和在 GridView1.Rows[index]
行(即grd
)中的GridView2的行.您确定第二个GridView至少有index+1
行吗?
而且,您正在创建并丢弃grd
声明中的GridView
实例.将这一行和下一行简化为一行,如下所示:
It looks like you are usingindex
as the index into two different collections:GridView1.Rows
and the Rows of the GridView2 that is in the rowGridView1.Rows[index]
(i.e.,grd
). Are you sure that this second GridView has at leastindex+1
rows?
Also, you''re creating and throwing away an instance ofGridView
in the declaration ofgrd
. Simplify this line and the next into one line, like this:
GridView grd = ((GridView)GridView1.Rows[index].FindControl("GridView2"));