http://dotnet.aspx.cc/ShowDetail.aspx?id=19BE9FAC-437A-4863-910D-9427554561B2

解决方案 »

  1.   

    用这个控件就行了:
    http://blog.mvpcn.net/cuike519/archive/2004/05/04/1276.aspx
      

  2.   

    用DataGrid的ItemDataBound事件啊!
    private void DataGrid1_ItemDataBound_1(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    e.Item.Attributes.Add("onclick","javascript:ChangeRowColor(this)");//单击当前行时
    e.Item.Attributes.Add("ondblclick","javascript:getData(this,"+e.Item.Cells[0].Text+")");//e.Item.Cells[0].Text取当前行第一列的值(双击当前行时)
    }
    }客户端代码
    <script language="javascript">
    var oldRow="";
    function ChangeRowColor(rowObj)//改变当前DataGrid中所选行的颜色
    {
    if(oldRow=="")
    {
    oldRow=rowObj;
    oldRow.style.backgroundColor='white';
    rowObj.style.backgroundColor='#FEE6A7';
    }
    if(oldRow!=rowObj)
    {
    oldRow.style.backgroundColor='white';
    rowObj.style.backgroundColor='#FEE6A7';
    oldRow=rowObj;
    }
    }

    function getData(rowObj,ID)//打开新窗口
    {
    ChangeRowColor(rowObj);
    var getControl=window.showModalDialog("HepatitisCheckCardView_p.aspx",ID,"dialogWidth=800px;dialogHeight=300px");
    }
    </script>
      

  3.   

    你在datagrid的前面加一列作为模板列checkbox cb;
    然后定义一个方法就可以了
    private string GetSelected(int i)
    {
      foreach(DataGridItem di in DataGrid1.Items)
        {
          if(((CheckBox) di.FindControl("cb")).Checked)
           {
             retrun di.Cell[i].Text.Tostring();
            }
         }
    }
      

  4.   

    楼上两位的方法我也都试过了。可是我的问题还是没解决。郁闷,本人实在是菜。
    magiccoder的方法,我没有找到调用DataGrid1_ItemDataBound_1的地方。
    dxphero的方法,我加不上模板列checkbox cb。只能加上按钮的模板列。
    各位仁兄,还有没有人有办法啊,小弟急死了!