Tutorial :How can I change order of the displayed columns in Dynamic Data?



Question:

For some of my Dynamic Data meta data tables I would like to control the order of the displayed columns. I have a custom page and I created a sub-directory named the same as my table. I copied the ListDetails.aspx and code file to the new directory. And changed AutoGenerateColumns to false(in Gridview) and AutoGenerateRows to false(DetailsView. None of them worked! Please please help me. J

Best regards,

Sahar

            <Columns>                <asp:DynamicField  DataField="DestFieldTypeDescription" />                <asp:DynamicField  DataField="DestFieldTypeName" />                 <asp:DynamicField  DataField="DestFieldTypeID" />                      </Columns>              <PagerStyle CssClass="footer" />                      <SelectedRowStyle CssClass="selected" />              <PagerTemplate>                  <asp:GridViewPager runat="server" />              </PagerTemplate>              <EmptyDataTemplate>                  There are currently no items in this table.              </EmptyDataTemplate>          </asp:GridView>  


Solution:1

When I get a problem like this where my changes are not being reflected in the output, the first thing I suspect is that I'm editing the wrong file.

Put something above or below the GridView, like "Hello World" and confirm that this file is being executed.

If the file is not getting executed, then its your route that isn't getting handed off to the right file. Your route is probably in Global.asax if your using the default template.


Solution:2

Make sure that you route to the "ListDetails" View for the correct Actions.

or in other words, enable combined-page mode: Uncomment these lines in the Global.asax.cs RegisterRoutes() method:

routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")  {      Action = PageAction.List,      ViewName = "ListDetails",      Model = model  });    routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")  {      Action = PageAction.Details,      ViewName = "ListDetails",      Model = model  });  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »