Click here to Skip to main content
11,790,987 members (55,277 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET

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"

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 at 31-Dec-12 6:13am
Thanks to your information, especially the 1st link is quite helpful to me.
_Amy at 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
0 ppolymorphe 385
1 OriginalGriff 385
2 Richard MacCutchan 118
3 Jochen Arndt 85
4 Maciej Los 70
0 OriginalGriff 1,329
1 Maciej Los 835
2 ppolymorphe 780
3 KrunalRohit 686
4 CPallini 661

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
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