首页 新闻 会员 周边

GridView的Insert功能疑惑

0
悬赏园豆:20 [已关闭问题]

在每一列 <FooterTemplate>中加了TextBox, 
<FooterTemplate> 
      <asp:TextBox ID="tbID" runat="server"> </asp:TextBox> 
</FooterTemplate> 
<FooterTemplate> 
      <asp:TextBox ID="tbName" runat="server"> </asp:TextBox> 
</FooterTemplate> 

在控制列 <FooterTemplate>加LinkButton, 
<FooterTemplate> 
      <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Insert">添加 </asp:LinkButton> 
</FooterTemplate> 

<InsertParameters> 
            <asp:Parameter Name="id" Type="Int32" /> 
            <asp:Parameter Name="name" Type="String" /> 
</InsertParameters> 是这样的 

然后单击LinkButton1没有效果 ,LinkButton1的CommandName换为New亦无效果

但后台 
            TextBox tbID = gv.FooterRow.FindControl("tbID") as TextBox; 
            TextBox tbName = gv.FooterRow.FindControl("tbName") as TextBox; 
            AccessDataSource1.InsertParameters["id"].DefaultValue = tbID.Text; 
            AccessDataSource1.InsertParameters["name"].DefaultValue = tbName.Text; 
            AccessDataSource1.Insert(); 
这样做就可以 

为什么不能自动实现?还要手动写代码

问题补充: 而Delete或Update实现类似功能时候,可以不写代码,当然自己写代码要处理一些逻辑和验证的问题,我只是想知道Insert能不能实现那种Delete自动的功能
SoXLiang的主页 SoXLiang | 初学一级 | 园豆:142
提问于:2009-10-22 10:14
< >
分享
其他回答(2)
0

当然要写代码,双击属性-事件中的Insert事件,编写插入代码

James.Ying | 园豆:1472 (小虾三级) | 2009-10-22 10:39
而Delete或Update实现类似功能时候,可以不写代码,当然自己写代码要处理一些逻辑和验证的问题,我只是想知道Insert能不能实现那种Delete自动的功能
支持(0) 反对(0) SoXLiang | 园豆:142 (初学一级) | 2009-10-22 10:54
0

设置属性AllowUserAddRows的属性设置为True就可以;应该是这个属性。

winzheng | 园豆:8797 (大侠五级) | 2009-10-22 12:43
貌似没有找到这个属性,我用的是GridView
支持(0) 反对(0) SoXLiang | 园豆:142 (初学一级) | 2009-10-22 13:45
0

在RowCommand事件里面处理吧。

天堂口 | 园豆:514 (小虾三级) | 2009-10-22 14:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册