问题
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>
How can I debug my code so I can see exactly what the value of Year is when it binds to the grid?
回答1:
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.
来源:https://stackoverflow.com/questions/15558720/how-can-i-debug-the-parameters-passed-when-using-an-inline-sqldatasource