前台代码:<asp:GridView ID="GridView1" runat="server" Height="16px" Width="800px" 
                    AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
                    BorderStyle="None" BorderWidth="60px" CellPadding="4" CssClass="style19" 
                    DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged" 
                    HorizontalAlign="Center" onrowediting="GridView1_RowEditing" 
                    DataKeyNames="classname" onrowdeleting="GridView1_RowDeleting">
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:BoundField DataField="collegename" HeaderText="collegename" 
                            SortExpression="collegename" ><ItemStyle Width = "150px" HorizontalAlign="Center" 
                                VerticalAlign="Middle"></ItemStyle></asp:BoundField>                          <asp:BoundField DataField="majorname" HeaderText="majorname" 
                            SortExpression="majorname" >
                            <ControlStyle BorderStyle="Groove" />
                            <ItemStyle Width = "180px" ForeColor="Black" HorizontalAlign="Center" 
                                VerticalAlign="Middle" Wrap="False"></ItemStyle></asp:BoundField>
                        <asp:BoundField DataField="classname" HeaderText="classname" 
                            SortExpression="classname" ><ItemStyle Width = "250px" HorizontalAlign="Center" 
                                VerticalAlign="Middle"></ItemStyle></asp:BoundField>
                        <asp:BoundField DataField="eduback" HeaderText="eduback" 
                            SortExpression="eduback" >
                        <ItemStyle Width = "80px" HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle></asp:BoundField>
                        <asp:BoundField DataField="entryear" HeaderText="entryear" 
                            SortExpression="entryear" ><ItemStyle Width = "50px" HorizontalAlign="Center" 
                                VerticalAlign="Middle"></ItemStyle></asp:BoundField>
                        <asp:BoundField DataField="gradyear" HeaderText="gradyear" 
                            SortExpression="gradyear" ><ItemStyle Width = "50px" HorizontalAlign="Center" 
                                VerticalAlign="Middle"></ItemStyle></asp:BoundField>
                        <asp:CommandField HeaderText="删除" ShowDeleteButton="True" >
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                        </asp:CommandField>
                       <asp:HyperLinkField 
                           DataNavigateUrlFields="classname" 
                          DataNavigateUrlFormatString="修改班级信息.aspx?id={0}" 
                               HeaderText="修改" Text="修改" DataTextFormatString="修改" >
                           <ItemStyle Width="50px" />
                        </asp:HyperLinkField>
                        <asp:ButtonField HeaderText="删除" Text="删除" />
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:jyxx1ConnectionString9 %>" 
                    
                    SelectCommand="SELECT DISTINCT collegename, majorname, classname, eduback, entryear, gradyear FROM classinfo" 
                    DeleteCommand="DELETE  FROM classinfo WHERE classname='&quot;GridView1.+DataKeys[e.NewSelectedIndex].Value.ToString()+ &quot;'">
                </asp:SqlDataSource>
假如&quot;GridView1.+DataKeys[e.NewSelectedIndex].Value.ToString()+ &quot;'改成一个具体的值就行了