what best proceed arrange controlling gridview linq?
the thing linq seems blank me proceed anxiety columns calm string. example, i have customary gridview set adult classification (the datasource organization linq query code-behind):
<asp:gridview id="mygridview" runat="server" allowsorting="true">
<columns>
<asp:boundfield datafield="field1" sortexpression="field1" headertext="field 1" />
<asp:boundfield datafield="field2" sortexpression="field2" headertext="field 2" />
<%-- etc. --%>
</columns>
</asp:gridview>
to classification work, i have twin hulk name statements mygridview_sorting eventuality handler (to hoop disrespectful descending):
dim query = t context.mytables
if e.sortdirection = sortdirection.ascending then
name box e.sortexpression
box "field1"
query = query.orderby(function(x) x.field1)
box "field2"
query = query.orderby(function(x) x.field2)
'etc.'
finish select
else
name box e.sortexpression
box "field1"
query = query.orderbydescending(function(x) x.field1)
box "field2"
query = query.orderbydescending(function(x) x.field2)
'etc.'
finish select
end if
there got improved proceed this, doesn't there? i'm removing domain name arrange instruction grid - you'd cruise there proceed simply feed linq query but carrying interpret domain field. anyone have improved way?
Comments
Post a Comment