全选     列名     口       AAA       ↑  ↓口       BBB       ↑  ↓口       CCC       ↑  ↓这个是我的 GirdView  贴图太麻烦。就这么画吧 呵呵↑ 跟↓ 都是 button    这个GirdView 是用Silverlight 画的其中在这个girdView里面 我把 id那列给隐藏了 还有 序列号那列也隐藏了
当我点 BBB这列后面那个 ↑ 这个箭头的时候我想得到BBB的当前行号 
这个里面的序列号的值 不是连续的
比如这个BBB 的序列号是 5 
下面那个CCC的序列号是 9我改怎么写当我点击BBB的时候 得到 BBB的 rowIndex ?  高手 帮忙。

解决方案 »

  1.   

    GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent;//取得触发命令的当前行 
    int index = row.RowIndex; 我一直是这样写的。。虽然有点土鳖。。但是还是有用滴
      

  2.   


    我的 e.CommandSource   点不出来。 
      

  3.   

    dataGridView.Rows.IndexOf(dataGridView.SelectedRows[0]);
      

  4.   


    用 Silverlight 画的 GirdView 不是 C#里面的。   这些我都点不出来。
      

  5.   

    int QuestionId = Convert.ToInt32(dataGridView1.CurrentRow.Cells["列名"].Value.ToString());
      

  6.   

    上面以为你是要获得Id,试试这句:
    int index=Convert.ToInt32(e.CommandArgument.ToString());
      

  7.   

      string strID = grdView.DataKeys[e.RowIndex].Value.ToString();
      

  8.   

     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int temp=Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString());
            if (e.CommandName == "mod")
            {
                    TxtTitle.Text = GridView1.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[1].Text;
                    txtcontent.Text = GridView1.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[2].Text;
                    createTime.Text = GridView1.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[3].Text;
                    Modfitlytime.Text = DateTime.Now.ToString();
                    ViewState["id"] = Convert.ToInt32(GridView1.Rows[Convert.ToInt32(e.CommandArgument.ToString())].Cells[0].Text);
                    showEidt(temp);
                       }
          
        }
    这是我以前项目当中用到的,你看看。。