首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

gridview的删除有关问题

2011-12-22 
gridview的删除问题formid form1 runat server divasp:GridViewID GridView1 runat serve

gridview的删除问题
<form   id= "form1 "   runat= "server ">
        <div>
                <asp:GridView   ID= "GridView1 "   runat= "server "   AllowPaging= "True "   AutoGenerateColumns= "False "
                        CellPadding= "4 "   DataKeyNames= "id "       ForeColor= "#333333 "  
                        GridLines= "None "     Style= "z-index:   100;   left:   163px;   position:   absolute;
                        top:   104px "   Width= "729px "   CssClass= "adminlist "   EnableViewState= "False "       EmptyDataText= "没有你所查找的记录 "   AllowSorting= "True "   OnSelectedIndexChanged= "GridView1_SelectedIndexChanged "   PageSize= "20 ">
                        <FooterStyle   BackColor= "#507CD1 "   Font-Bold= "True "   ForeColor= "White "   />
                        <Columns>
                        <asp:TemplateField>
                                                        <ItemTemplate>                                                                                
                                                                <asp:CheckBox   ID= "chkSelect "   runat= "server "/>                                                                                  
                                                        </ItemTemplate>
                                                        <HeaderTemplate>
                                              <input   id= "chkAll "   onclick= "SelectAllCheckboxes(this); "   runat= "server "   type= "checkbox "     />                                                                          


                                                        </HeaderTemplate>
                                                              <ItemStyle   HorizontalAlign= "Left "   Width= "25px "   />
                                                      </asp:TemplateField>
                               
               
               
                                <asp:BoundField   DataField= "btsrxm "   HeaderText= "被投诉人姓名 "       SortExpression= "btsrxm "   >
                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                </asp:BoundField>
                                <asp:BoundField   DataField= "cddm "   HeaderText= "车队 "     SortExpression= "cddm "   >
                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                </asp:BoundField>
                                <asp:BoundField   DataField= "tsxz "   HeaderText= "投诉性质 "     SortExpression= "tsxz "   >
                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                </asp:BoundField>
                                <asp:BoundField   DataField= "tsnr "   HeaderText= "投诉内容 "     SortExpression= "tsnr "   >


                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                          </asp:BoundField>
                                            <asp:BoundField   DataField= "tsrq "   HeaderText= "投诉日期 "     SortExpression= "tsrq "   >
                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                </asp:BoundField>
                                <asp:BoundField   DataField= "jbr "   HeaderText= "经办人 "     SortExpression= "jbr "   >
                                        <ItemStyle   HorizontalAlign= "Left "   VerticalAlign= "Middle "   />
                                        <HeaderStyle   HorizontalAlign= "Left "   />
                                </asp:BoundField>
                                <asp:TemplateField   ShowHeader= "False ">
                                        <ItemTemplate>
                                      <input   ID= "id "   name= ' <%#   Eval( "ID ")   %> '   type=hidden   Value= ' <%#   Eval( "ID ")   %> '     />
                                       
                                      <a   href= "addfuwu.aspx?action=edit&id= <%#   Eval( "ID ")   %> "   id= "a2 "   > 修改 </a>    
                                          <a   href= "addfuwu.aspx?action=view&id= <%#   Eval( "ID ")   %> "   id= "a1 "   > 查看 </a>    


                                   
                                                <asp:Button   ID= "Button1 "   runat= "server "   CausesValidation= "False "   CommandName= "Delete "
                                                        Text= "删除 " OnClientClick= "return   confirm( '您确认删除该记录吗? '); "     />
                                        </ItemTemplate>
                                </asp:TemplateField>
                        </Columns>
                          <EmptyDataTemplate> 没有你所查找的记录 </EmptyDataTemplate>
                        <RowStyle   BackColor= "#EFF3FB "   />
                        <EditRowStyle   BackColor= "#2461BF "   />
                        <SelectedRowStyle   BackColor= "#D1DDF1 "   Font-Bold= "True "   ForeColor= "#333333 "   />
                        <PagerStyle   BackColor= "#2461BF "   ForeColor= "White "   HorizontalAlign= "Center "   />
                        <HeaderStyle   BackColor= "#507CD1 "   Font-Bold= "True "   ForeColor= "White "   />
                        <AlternatingRowStyle   BackColor= "White "   BorderStyle= "Groove "   />
                        <EmptyDataRowStyle   VerticalAlign= "Top "   />
                        <PagerTemplate>
                           
               
 
                        </PagerTemplate>
                </asp:GridView>
                &nbsp;
               
                </div>
                  <div   style= "text-align:left ">                                    
                          <br   />


                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     &nbsp;
                          </div>
       
        <table   border= "1 "   cellpadding= "0 "   cellspacing= "0 "   bordercolorlight= "#FFFFFF "   bordercolordark= "#E6E6E6 "   bgcolor= "#FFFFFF "   style= "left:   190px;   width:   73%;   position:   relative;   top:   -6px;   height:   24px ">  
<tr> <td   style= "height:   24px;   width:   200px; ">  
<asp:Button   ID= "Button2 "   runat= "server "   Text= "批量删除用户 "   CommandName= "Delete "     OnClientClick= "return   confirm( '您确认删除该记录吗? '); "   OnClick= "Button2_Click "/>
        &nbsp;
</td>  
<td   align=right   style= "height:   24px;   width:   325px; ">  
          <webdiyer:AspNetPager   ID= "AspNetPager1 "   runat= "server "   Style= "position:   relative "   OnPageChanged= "AspNetPager1_PageChanged "   PageSize= "20 "   Width= "310px "   FirstPageText= "首页       "       LastPageText= "       末页 "       NextPageText= "下一页 "       PrevPageText= "上一页 ">
                </webdiyer:AspNetPager>
               
                &nbsp;&nbsp; </td>  
</tr> </table>  
                <asp:Label   ID= "Label1 "   runat= "server "   Height= "20px "   Style= "left:   47px;   position:   relative;
                        top:   58px "   Text= "Label "   Width= "87px "> </asp:Label>
               
               
</form>

[解决办法]
把if(!IsPostBack)去掉

热点排行