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

Posted on 2009-02-22
Medium Priority
Last Modified: 2013-12-17
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


Question by:R8VI
1 Comment
LVL 15

Accepted Solution

aibusinesssolutions earned 2000 total points
ID: 23706022
Set the parameter in the form_load

SqlDataSource1.SelectParameters["videoid"].DefaultValue = Request.QueryString["video"].ToString()

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question