为什么sqldatasource有参数且有默认值时,repeater控件取不出值,具体代码如下:
<form id="form1" runat="server"><div>
<ul>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<li>
<%#Eval("Newsnr") %>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XinxixiConnectionString %>"
SelectCommand="SELECT [NewsID], [NewsTitle], [Newsnr], [Newsgjz], [FUsername], [Fbtime], [lanMuID], [yueDucishu], [souYetuijian] FROM [Xinxixi_News] WHERE ([lanMuID] = @lanMuID)">
<SelectParameters>
<asp:Parameter DefaultValue="912ba373-2305-49c4-b125-014c56b04f28"
Name="lanMuID" Type="Object" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
//当没有defaultvalue时从数据库中可以直接取出数据,看另外一种的写法
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XinxixiConnectionString %>"
SelectCommand="SELECT [NewsID], [NewsTitle], [Newsnr], [Newsgjz], [FUsername], [Fbtime], [lanMuID], [yueDucishu], [souYetuijian] FROM [Xinxixi_News]">
</asp:SqlDataSource>,这种能够取出来
他们两个的区别是上面的多了一个
<SelectParameters>
<asp:Parameter DefaultValue="912ba373-2305-49c4-b125-014c56b04f28"
Name="lanMuID" Type="Object" />
</SelectParameters>
我是一个新手,麻烦详细一点 --------------------编程问答-------------------- 加上查询条件就没有值了,没有满足条件的记录 --------------------编程问答-------------------- 把这句在数据库中执行以下应该是查询不到数据的
SELECT [NewsID], [NewsTitle], [Newsnr], [Newsgjz], [FUsername], [Fbtime], [lanMuID], [yueDucishu], [souYetuijian] FROM [Xinxixi_News] WHERE ([lanMuID] = ‘912ba373-2305-49c4-b125-014c56b04f2’)
补充:.NET技术 , 非技术区