http://dotnet.aspx.cc/ShowDetail.aspx?id=FF130C7F-3650-4DA6-8943-8AA4AF3E3459private void Button2_Click(object sender, System.EventArgs e)
{
bool ischeck=false;
int i=0;
foreach(DataGridItem tem in DataGrid1.Items) 

ischeck=((CheckBox)tem.FindControl("CheckBox1")).Checked;
if(ischeck)
{
minvoice_id=Convert.ToString(tem.Cells[1].Text);
i=i+1;
}
}
if (i==0)
{
Response.Write("<script>alert(\"还没选择,请选择后再运行!!!\")</script>");
}
else if(i==1)
{
OleDbCommand com=new OleDbCommand("DELETE 表 WHERE 序号="minvoice_id",(OleDbConnection)Application["Con"]);\\或者写存储过程
com.ExecuteNonQuery();
Response.Write("<script>alert(\"删除成功!\");location.href='wltkbindex.aspx';</script>");
}
else
{
Response.Write("<script>alert(\"只能一次选择一条记录!\")</script>");
}
}

解决方案 »

  1.   

    休假了一段时间,好久没上来看了。这个问题是针对应用程序的,不是web程序(web程序的datagrid方面的东西我都做出来了),所以forever10(永远的10号) 提供的例子恐怕对这个问题不适用,不过非常感谢forever10(永远的10号) 的解答。
    这个问题仍在思考中...望各位给予建议,谢谢!
      

  2.   

    我也想解决这个问题
    datagrid有两个属性:DataGridBoolColumn这个就是复选框的
                       DataGridTextBoxColumn
    想在datagrid 中添加任何控件,都可以通过这两个属性进行
    我现在可以做到在网格中添加复选框,和下拉列表,但是还没有办法将数据源中的数据选返给复选框,还请朋友们研究一下,以下是我的一部分代码:
    new DataGridTableStyle();
    myGridStyle.MappingName = "Customers"; // Create four DataGridColumnStyle objects.
    DataGridColumnStyle colStyle1 =
    new DataGridTextBoxColumn();
    colStyle1.MappingName = "customersid";
    colStyle1.HeaderText="customersid";
       
    DataGridColumnStyle colStyle2 =
    new DataGridTextBoxColumn();
    colStyle2.MappingName = "name";
    colStyle2.HeaderText="name";




    DataGridBoolColumn colStyle3 =
    new DataGridBoolColumn();
    colStyle3.MappingName = "address";
    colStyle3.HeaderText="address";
    colStyle3.FalseValue="0";
    colStyle3.TrueValue="1";
    colStyle3.NullText="";
    colStyle3.AllowNull=false;





    DataGridColumnStyle colStyle4 =
    new DataGridTextBoxColumn();
    colStyle4.MappingName = "photo";
    colStyle4.HeaderText="photo";
    // Create four DataGridColumnStyle objects.

    // Add column styles to table style.
    myGridStyle.GridColumnStyles.Add(colStyle1);
    myGridStyle.GridColumnStyles.Add(colStyle2);   
    myGridStyle.GridColumnStyles.Add(colStyle3);
    myGridStyle.GridColumnStyles.Add(colStyle4);
    // Add the grid style to the GridStylesCollection.
    datagrid1.TableStyles.Add(myGridStyle);
      

  3.   

    只知道打开一个页面如果想在winform中,就要使用web browser(自定义工具栏添加)如果是弹出来,直接用Label.Text="<a href='#'>链接</a>"
      

  4.   

    在winform 下如果象超连接那样弹出窗体,我可以给个参考:
    Private Sub MyDataGrid_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyDataGrid.CurrentCellChanged
            Dim tempform As New Newform     'newform 为你要弹出的窗体
            If MyDataGrid.CurrentCell.ColumnNumber = 0 Then   ‘在第一列弹出
                
                tempform.TextBox1.Text = MyDataGrid.Item(MyDataGrid.CurrentCell)
                tempform.Show()
            End If
        End Sub也可以在第一列加上一超连接的Lable
    dim LinkCol as new Linklable
    Mydatagrid.controls.add(linkCol)