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

关于GridView自带更新的有关问题,如何更新不啊

2012-02-06 
关于GridView自带更新的问题,怎么更新不啊??asp:GridViewID GridView1 runat server AllowPaging

关于GridView自带更新的问题,怎么更新不啊??
<asp:GridView   ID= "GridView1 "   runat= "server "   AllowPaging= "True "   AllowSorting= "True "
                        AutoGenerateColumns= "False "   CellPadding= "4 "   DataKeyNames= "lid "   DataSourceID= "topickindsSqlDataSource "
                        ForeColor= "#333333 "   GridLines= "None "   PageSize= "20 ">
                        <FooterStyle   BackColor= "#507CD1 "   Font-Bold= "True "   ForeColor= "White "   />
                        <Columns>
                                <asp:BoundField   DataField= "lid "   HeaderText= "类别ID "   InsertVisible= "False "
                                        ReadOnly= "True "   SortExpression= "lid "   />
                                <asp:BoundField   DataField= "ltype "   HeaderText= "类别名称 "   SortExpression= "ltype "   />
                                <asp:TemplateField   ShowHeader= "False ">
                                        <EditItemTemplate>
                                                <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   CausesValidation= "True "   CommandName= "Update "
                                                        Text= "更新 "> </asp:LinkButton>
                                                <asp:LinkButton   ID= "LinkButton2 "   runat= "server "   CausesValidation= "False "   CommandName= "Cancel "
                                                        Text= "取消 "> </asp:LinkButton>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                                <asp:LinkButton   ID= "LinkButton1 "   runat= "server "   CausesValidation= "False "   CommandName= "Edit "


                                                        Text= "编辑 "> </asp:LinkButton>
                                                <asp:LinkButton   ID= "LinkButton2 "   runat= "server "   CausesValidation= "False "   CommandName= "Delete "
                                                        OnClientClick= '{if(confirm( "确定要删除吗? ")){return   true;}return   false;} '   Text= "删除 "> </asp:LinkButton>
                                        </ItemTemplate>
                                </asp:TemplateField>
                        </Columns>
                        <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 "   />
                </asp:GridView>
                <asp:SqlDataSource   ID= "topickindsSqlDataSource "   runat= "server "   ConflictDetection= "CompareAllValues "
                        ConnectionString= " <%$   appSettings:LawConnStr   %> "   DeleteCommand= "DELETE   FROM   dbo.quan_type   WHERE   (lid   =   @lid) "
                        InsertCommand= "INSERT   INTO   [quan_type]   ([ltype])   VALUES   (@ltype) "
                        OldValuesParameterFormatString= "original_{0} "   SelectCommand= "SELECT   [lid],   [ltype]   FROM   [quan_type]   ORDER   BY   [lid]   DESC "
                        UpdateCommand= "UPDATE   [quan_type]   SET   [ltype]   =   @ltype   WHERE   ([lid]   =   @lid) ">


                        <DeleteParameters>
                                <asp:Parameter   Name= "lid "   Type= "Int32 "   />
                        </DeleteParameters>
                        <UpdateParameters>
                                <asp:Parameter   Name= "ltype "   Type= "String "   />
                                <asp:Parameter   Name= "lid "   Type= "Int32 "   />
                        </UpdateParameters>
                        <InsertParameters>
                                <asp:Parameter   Name= "ltype "   Type= "String "   />
                        </InsertParameters>
                </asp:SqlDataSource>

上面是所有代码,更新出错,提示:必须声明变量   '@lid '。  

点删除没反应,谁可以帮我改下啊??   谢谢!!

[解决办法]
@lid
这是数据库中的变量,程序中不能用
把他换成程序认识的变量
[解决办法]
Up

热点排行