3

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?

loyalflow
  • 14,275
  • 27
  • 107
  • 168

1 Answers1

7

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.

Steve Wellens
  • 20,506
  • 2
  • 28
  • 69