Click here to Skip to main content
13,550,805 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have a select statement in code infront as following:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VSGIHURConnectionString %>"
   SelectCommand="SELECT distinct size,UniformID FROM [uniforminfo] where UniformName='+lbl_uniformid+' and status= 'a' ORDER BY UniformID">

the UniformName is based on the selection of lbl_uniformid in the grid. The question is how can i rewrite the above sql statement "where UniformName='+lbl_uniformid+'" based on the user selected uniformid (means when user choose a uniformid in the grid then the select statement will select a correct size based on the user chosen uniformid)?

Here is the code of UniformName in the grid

<asp:TemplateField HeaderText="Type Of Uniform" Visible="true" ItemStyle-Width="200" >
            <asp:Label ID="lbl_uniformid" runat="server" Text='<%#Eval("uniformgroupname") %>'


         <asp:TextBox ID="ddl_uniformgroupname" runat="server" AutoPostBack="true" runat="server"

            BackColor="White" CompletionListCssClass="completeListStyle"

            Text='<%# Eval("uniformgroupname") %>' ontextchanged="txt_ddl_uniformgroupname"

            style="font-family: 'Century Gothic';" Visible="true"

        <asp:AutoCompleteExtender ID="ddl_uniformgroupname_AutoCompleteExtender" runat="server" CompletionInterval="100"

    CompletionListCssClass="completeListStyle" DelimiterCharacters="" Enabled="True"

    MinimumPrefixLength="0" ServiceMethod="GetCompletion_ddl_uniformgroupname" ServicePath=""


Appreciate to anyone who want to assist my problem.

Thanks a lot & H@ppy 2013.

Posted 30-Dec-12 17:02pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The way you are doing this, is totally wrong. You need to use Parameters in SqlDataSource Control. It seems you need to do a lots of practice on it. Just visit the below links:
Using Parameters with the SqlDataSource Control[^]
Use a SqlParameter to represent stored procedure return values and output parameters[^]
SqlParameter Example, How to use SqlParameter in ASP.Net C#, SqlParameter, SqlDataReader, SqlCommand, SqlConnection Example[^]

singping 31-Dec-12 6:13am
Thanks to your information, especially the 1st link is quite helpful to me.
_Amy 31-Dec-12 7:10am
Welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180515.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100