Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i'm new in linq i want to know if my query is true

this is my query in sql server
SQL
select s.LIBELE_STATION,na.LIBELE_NA,sa.SEUIL_ALERTE
from NIVEAU_ALERTE na, ALARME_STATION sa, PARAMETRE_MESURE pm , STATION s
where sa.ID_NA=na.ID_NA
and sa.ID_PM=pm.ID_PM
and sa.ID_STATION=s.ID_STATION
and s.ID_STATION='Ain Sebou'
and pm.LIBELE_PM='Niveau'


and in linq

CSS
var alar = from sa in context.ALARME_STATION
                              join na in context.NIVEAU_ALERTE on sa.ID_NA equals na.ID_NA
                              join pm in context.PARAMETRE_MESURE on sa.ID_PM equals pm.ID_PM
                              join s in context.STATIONs on sa.ID_STATION equals s.ID_STATION
                              where pm.LIBELE_PM == val && s.ID_STATION == drp_state.SelectedValue
                              select new
                              {
                                  libel = pm.LIBELE_PM,
                                  na = na.LIBELE_NA,
                                  seul = sa.SEUIL_ALERTE
                              };

if yes why i have error wich is display in pic

http://www.mediafire.com/view/4gdm1xnwal8is9c/code2.png[^]

i want to bind gridview as my code apear
Posted
Comments
F-ES Sitecore 11-Jul-15 10:39am    
What is the error in English?
Member 11573837 11-Jul-15 11:16am    
hi F-ES Sitecore
thank you for answering me
this's the error
DataBinding : '<>f__AnonymousType6`3[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'does not include a property called ' ID_PM ' .
F-ES Sitecore 11-Jul-15 12:19pm    
It seems that your grid view might have a field bound to a column called ID_PM, but your linq is returning a collection that only has libel, na and seul. Maybe you need to add a new property to the "new { ... }" you are creating.
Member 11573837 11-Jul-15 17:42pm    
hi F-ES Sitecore,
sorry fo being late to replay this is my gridview

<asp:GridView ID="gv_alerte" runat="server">
<columns>
<asp:TemplateField HeaderText="Libele" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Size="13px">
<itemtemplate>
<asp:Label ID="libel" runat="server" Text='<%# Bind("libel") %>'>


<asp:TemplateField HeaderText="Niveau d'alerte" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Size="13px">
<itemtemplate>
<asp:Label ID="na" runat="server" Text='<%# Bind("na") %>'>


<asp:TemplateField HeaderText="Seuil d'alerte" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Size="13px">
<itemtemplate>
<asp:Label ID="seul" runat="server" Text='<%# Bind("seul") %>'>



Member 11573837 11-Jul-15 18:01pm    
hi F-ES Sitecore,
thank you it work now i change id of my grid view because in my webform i have 2 grid and i bind the first one now it works thanks o lot

1 solution

Quote:
thank you it work now i change id of my grid view because in my webform i have 2 grid and i bind the first one now it works thanks o lot
Adding to close the thread.
 
Share this answer
 

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