Search code examples
.netentity-frameworkwidthdynamic-data

setting width of datagrid generated by Dynamic data (Entity framework, in .net)


I am generating editable data grids from tables using dynamic data, however, i am unable to set the width of the tables/grids.

Can someone please point me to an article/ or suggest how i can do this?

Thanks in advance.

Regards. Kulu.


Solution

  • Styles are applied to the pages generated by DynamicData with CSS. By Default the GridView on the List.aspx Page Template has a CssClass="gridview". That class has quite a few styles defined in the default Site.css file. including this one:

    table.gridview { width: 100%; }
    

    You can change the width value there to make a Global change everywhere this class is used (probably not what you are looking for). If you would like to change the width for just one entity/page you should probably make a Custom Page for that entity.

    Steps

    1. Create a new Folder within the ~/DynamicData/CustomPages directory with the same name as the EntitySet/Collection of your entity (ex: ~/DynamicData/CustomPages/Employees for the Employee entity)
    2. Copy the List.aspx page from the ~/DynamicData/PageTemplates directory into the new directory you just created. (you may need to adjust the namespace of the CodeBehind/aspx file)
    3. Using a custom CSS class (or explicitly in the .aspx file) change the width of the GidView on the page.

    more info: http://www.asp.net/learn/3.5-SP1/video-445.aspx