Sqldatasource没有在回发时更新 [英] Sqldatasource is not updating on postback

查看:57
本文介绍了Sqldatasource没有在回发时更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发表评论页面。我已经在数据库中存储了注释,它已经存储但我的asp:repeater在回发后没有更新。请帮忙。

这是我的代码:



i want to make a comment page. i have stored comments in database, it is getting stored but my asp:repeater is not updating after postback. please help.
this is my code:

<tr>
<asp:Repeater ID="repeater1" runat="server" DataSourceID="SqlDataSource1" >
<ItemTemplate>
<tr>
    <td>
        <%# Eval("Comment") %>
        <br />
    </td>


    <td align="right"> By: <%# Eval("UserName") %>
    <br />
    </td>
</tr>
</ItemTemplate>
</asp:Repeater>

</tr>
<tr>
<td><asp:TextBox ID="txtComment" runat="server" Height="110px" MaxLength="35565"

        Width="752px" TextMode="MultiLine"></asp:TextBox></td>
</tr>
<tr>
    <td align="right">
    <asp:Button ID="btnPost" runat="server" Text="Post" Visible="false"

            onclick="btnPost_Click" />
    &nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="btnCmmnt" runat="server" Text="Comment" onclick="btnCmmnt_Click"/>

    </td>
</tr>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"

        ConnectionString="<%$ ConnectionStrings:WebCommentConnectionString %>"

        SelectCommand="SELECT * FROM [Comment] where [Post_ID]=12"></asp:SqlDataSource>
</table>

推荐答案

ConnectionStrings:WebCommentConnectionString %>

SelectCommand = SELECT * FROM [Comment]其中[Post_ID] = 12 > < / asp:SqlDataSource >
< / table >
ConnectionStrings:WebCommentConnectionString %>" SelectCommand="SELECT * FROM [Comment] where [Post_ID]=12"></asp:SqlDataSource> </table>


可以包括btnCmmnt_Click事件,所以我们可以看到你的代码发生了什么?
Can you include the btnCmmnt_Click event, so we can see what''s going on with your code?


我找到了解决方案。我只需要在将注释存储到数据库后刷新页面。谢谢。
i found solution. i just needed to refresh the page after storing comment into database. thank you.


这篇关于Sqldatasource没有在回发时更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆