Click here to Skip to main content
Rate this: bad
good
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"
            >
        </asp:TextBox>
        <asp:AutoCompleteExtender ID="ddl_uniformgroupname_AutoCompleteExtender" runat="server" CompletionInterval="100"
    CompletionListCssClass="completeListStyle" DelimiterCharacters="" Enabled="True"
    MinimumPrefixLength="0" ServiceMethod="GetCompletion_ddl_uniformgroupname" ServicePath=""
    TargetControlID="ddl_uniformgroupname">
</asp:AutoCompleteExtender>
    
     </EditItemTemplate>
    </asp:TemplateField>
 

Appreciate to anyone who want to assist my problem.
 
Thanks a lot & H@ppy 2013.
 
sp
Posted 30-Dec-12 18: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 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 DamithSL 485
1 Maciej Los 288
2 OriginalGriff 229
3 Zoltán Zörgő 200
4 BillWoodruff 170
0 OriginalGriff 7,934
1 DamithSL 6,084
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,174
4 Kornfeld Eliyahu Peter 4,539


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