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?

share|improve this question

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.