Click here to Skip to main content
12,348,594 members (67,855 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi,

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">
   </asp:SqlDataSource>

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" >
        <ItemTemplate>
            <asp:Label ID="lbl_uniformid" runat="server" Text='<%#Eval("uniformgroupname") %>'
                Visible="true"></asp:Label>
 
        </ItemTemplate>
          <EditItemTemplate>
         <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.

sp
Posted 30-Dec-12 17:02pm

1 solution

Rate this: bad
 
good
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[^]


--Amit
  Permalink  
Comments
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 | Mobile
Web02 | 2.8.160621.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2016
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