设置DataGrid的SelectedIndex可以指定选择行(-1为不选)设置DataGrid的EditIndex可以指定编辑行(-1为不选)当SelectedIndex和EditIndex冲突时,EditIndex优先。

解决方案 »

  1.   

    用commandcolum列,将commandname="select"就可以选中.如果将commandname="edit",将bindcolum的readonly="false",在edit事件中设置editindex=e.itemindex再绑定就可以修改.我一般是打开一个模式窗口
      

  2.   

    DataGrid选中增加选择按钮列即可,如果在dataGrid中修改,只能增加模板列,在其中使用TextBox控件
      

  3.   

    对于triout兄的方法:
        我是想在页面上通过鼠标去选择,首先得让DataGrid判断鼠标是在哪一行上单击或者是双击,才能设置SelectedIndex或EditIndex的数值,那么我怎么用DataGrid获取它被选中的行?对于flygoldfish的方法:
        就是说我需要对DataGrid添加列吗?使用DataGrid的一个好处是设置DataSource和绑定之后就自动生成,这样要手工添加或在运行中动态添加,那么它比其他List之类的控件的优越性就体现不出来了吗?对于newliuwei的方法:
        如何在运行中动态添加摸板列,可否给个简要的例子看看。
      

  4.   

    示例看
    http://chs.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/doc_datagrid.aspx
      

  5.   

    我的DataGrid初试化形式如下:
    this.oracleDataAdapter1.Fill(ds);
    this.DataGrid_Manager.DataSource = ds;  //ds是一个DataSet
    this.DataGrid_Manager.DataBind();那么我需要动态添加列,要在什么位置才行啊?