How can I debug the parameters passed when using an inline sqldatasource?

牧云@^-^@ 提交于 2020-01-04 05:53:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!