如何调试使用内联的SqlDataSource时传递的参数? [英] How can I debug the parameters passed when using an inline sqldatasource?
本文介绍了如何调试使用内联的SqlDataSource时传递的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我有某种一个的.aspx页面上的DataGrid或中继器,而我的数据源定义内联这样的:
Say I have some sort of datagrid or repeater on a .aspx page, and my data source is defined inline like:
<asp:SqlDataSource ID="ds1" runat="server" ConnectionString="..."
SelectCommand="some_proc" ...>
<SelectParameters>
<asp:ControlParameter ControlID="ddlYear" Name="Year" .. />
</SelectParameters>
</asp:SqlDataSource>
我如何调试我的code,所以我可以看到正是一年的价值是当它绑定到网格?
How can I debug my code so I can see exactly what the value of Year is when it binds to the grid?
推荐答案
您可以挂接到SqlDataSource的事件:
You can hook into the SqlDataSource events:
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
foreach (DbParameter P in e.Command.Parameters)
{
Response.Write(P.ParameterName + "<br />");
Response.Write(P.DbType.ToString() + "<br />");
Response.Write(P.Value.ToString() + "<br />");
}
}
当然,你可能需要将输出发送到调试窗口。
Of course, you may want to send the output to the debug window.
这篇关于如何调试使用内联的SqlDataSource时传递的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文