解决方案 »

  1.   

    ASP.NET数据控件GridView编辑模板传值设置问题
    //GridView设置
     <asp:GridView ID="ClassList" runat="server" AutoGenerateColumns="False"
                            CellPadding="4" Font-Size="11pt" GridLines="None" Width="468px" OnRowCancelingEdit="ClassList_RowCancetingEdit" OnRowDeleting="ClassList_RowDeleting" OnRowEditing="ClassList_RowEditing" OnRowUpdating="ClassList_RowUpdating" ForeColor="#333333" AllowPaging="True" AllowSorting="True" OnPageIndexChanging="ClassList_PageIndexChangging" PageSize="6" OnRowDataBound="ClassList_RowDataBound">
                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <Columns>
                                <asp:TemplateField HeaderText="选项">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="CheckBox1" runat="server" Font-Size="9pt" Height="1px" Width="1px" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="ST_c_id" HeaderText="类型编号" ReadOnly="True" />
                                <asp:BoundField DataField="ST_c_name" HeaderText="文章类别" />
                                <asp:CommandField HeaderText="编辑" ShowEditButton="True" />
                                <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
                            </Columns>
                            <SelectedRowStyle BackColor="#C5BBAF" ForeColor="#333333" Font-Bold="True" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                            <RowStyle BackColor="#E3EAEB" />
                            <EditRowStyle BackColor="#7C6F57" />
     </asp:GridView>//codego.net/tags/11/1/
    //编辑设置传值修改数据行绑定信息显示
    protected void ClassList_RowEditing(object sender, GridViewEditEventArgs e)
        {
            ClassList.EditIndex = e.NewEditIndex;
            ST_Type_List_Bind();
        }
        protected void ClassList_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string sqlstr0 = "update ST_class set ST_c_name='" + ((TextBox)(ClassList.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() + "'where ST_c_id='" + ClassList.DataKeys[e.RowIndex].Value.ToString() + "'";
            //调用公共类中的ExceSQL方法执行SQL语句
            My_sqldata.ExceSQL(sqlstr0);
            ClassList.EditIndex = -1;
            
            ST_Type_List_Bind();
        }
      

  2.   

    在RowDataBound时,给每行添一个删除按钮用<a href="void(0)" onclick="JS事件">删除</a>
    这个Js事件就是用来传值和弹出窗口的