sql data source pass a variable, c#, asp.net

Hi I have the follwoing code

in aspx page

  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LiveConnectionString %>"
        SelectCommand="select commentsleftby, comments from ratingsandcomments where Video_ID = @videoid ">
          <asp:parameter name="videoid" defaultvalue ="" />


c# page

protected void _data_Selecting(object sender, SqlDataSourceSelectingEventArgs

        e.Command.Parameters["videoid"].Value = Request.QueryString["Video"].ToString();

what i want to do is get the value from the query string and pass it into the datasource

what am i doing wrong


Who is Participating?
Set the parameter in the form_load

SqlDataSource1.SelectParameters["videoid"].DefaultValue = Request.QueryString["video"].ToString()
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.