DataGrid1_ItemDataBound事件中e.Item.ItemIndex.ToString();

解决方案 »

  1.   

    应该是在ItemCommand事件处理当中写吧
      

  2.   

    应该是在ItemCommand事件处理当中写吧
      

  3.   

    快乐王子的没错。
    是从0开始计的。
    e.Item.ItemIndex;//int型
      

  4.   

    在DataGrid的模板列中:设置:
    <asp:ButtonColumn Text="select" CommandName="Select">
    <HeaderStyle Width="10%" ></HeaderStyle>
    <ItemStyle BackColor="#CCFFFF"></ItemStyle>
    </asp:ButtonColumn>
    主要是ButtonColumn的CommandName属性设为Select,ButtonType为默认,也就是ButtonType=Linkbutton.
    然后在DataGrid中就可以触发SelectIndexChang事件:
    DataGrid1.SelectedIndex就是当前选择的行号。有源码:asp.net(c#)+sqlserver
    如想要:msn: [email protected]索要。