Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i use alias names for columns, working fine when using without alias for columns
ERROR: A field or property with the name was not found on the selected data source

XML
<asp:SqlDataSource ID="MONTHLYPAY" runat="server"
                ConnectionString="<%$ ConnectionStrings:STUDENTConnectionString %>"

                    SelectCommand="Select  A.STU_ID as ID,  FIRST_NAME ,  B.PAY_TYPE ,  PAID_AMMOUNT ,  PAID_DATE  from MONTHLY_PAY_INFO AS B ,STUDENT_CONTACTS AS A Where B.STU_SNO = A.SNO AND B.STU_ID  = @Sstsno ORDER BY PAID_DATE desc">
                    <SelectParameters>
            <asp:ControlParameter Name="Sstsno" ControlID="search" Type="String" />
        </SelectParameters>
            </asp:SqlDataSource>
Posted

Hear PAID_DATE as DATE



XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
       DataSourceID="SqlDataSource1">
       <Columns>
           <asp:BoundField ApplyFormatInEditMode="True" DataField="PAID_DATE"
               HeaderText="DATE" SortExpression="PAID_DATE" />
       </Columns>
   </asp:GridView>
   <asp:SqlDataSource ID="SqlDataSource1" runat="server"
       ConnectionString="<%$ ConnectionStrings:STUDENTConnectionString %>"
       SelectCommand="SELECT [PAID_DATE] FROM [MONTHLY_PAY_INFO]">
   </asp:SqlDataSource>
 
Share this answer
 
You haven't specified a PropertyName[^] on the ControlParameter.
 
Share this answer
 
Comments
surendra4u 22-Aug-13 17:09pm    
sorry, I didn't get you, can explain please
Maarten Kools 22-Aug-13 17:16pm    
The ControlParameter class takes a property value from the Control (specified by ControlID property) and uses it as the named parameter (as specified by the Name property) for a SqlDataSource. However, the ControlParameter cannot guess what property value to get from the Control; it could be Value, or SelectedValue or maybe Text. Though there are some defaults (as explained by the documentation), judging from the error you get, it doesn't have a clue what property to use. So you'll need to specify that using the PropertyName property. Also see the example in the documentation page I linked to.
surendra4u 22-Aug-13 18:20pm    
Finally i got the code (use this in coloumns tag)
<columns> <asp:BoundField ApplyFormatInEditMode="True" DataField="PAID_DATE"
HeaderText="DATE" SortExpression="PAID_DATE" />

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900