Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<div class="row">

               <table id="header" style="background-color: #e0b4b4; font-size:small; height:30px">
                   <tr>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Type </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Product Details </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Asset No </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Product Description </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Brand </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Serial No </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Barcode </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Vendor </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Vendor Information </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Purchase Date </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Warrenty Year </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Warrenty Expire </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Remarks </td>
                       <td style="font-weight: bold; width:70px; border: 1px solid black"> Action </td>
                   </tr>

               </table>

               <div style="font-size:small; height:600px; overflow-y: scroll; overflow-x:auto;">
                   <asp:GridView ID="empgrid" runat="server" CssClass="table table-striped" GridLines="Both"  DataKeyNames="ID" AutoGenerateColumns="false">


                       <Columns>
                       <asp:BoundField  DataField="Type"/>
                       <asp:BoundField  DataField="Prodtype"/>
                       <asp:BoundField  DataField="Assetno"/>
                       <asp:BoundField  DataField="Prodesc"/>
                       <asp:BoundField  DataField="Brand"/>
                       <asp:BoundField  DataField="Slno"/>
                       <asp:BoundField  DataField="Barcode"/>
                       <asp:BoundField  DataField="Vendor"/>
                       <asp:BoundField  DataField="Vendorinfo"/>
                       <asp:BoundField  DataField="Purchasedate" DataFormatString = "{0:dd/MM/yyyy}"/>
                       <asp:BoundField  DataField="Warryear" DataFormatString = "{0:dd/MM/yyyy}"/>
                       <asp:BoundField  DataField="Warrexp" DataFormatString = "{0:dd/MM/yyyy}"/>
                       <asp:BoundField  DataField="Remarks"/>

                           <asp:TemplateField>
                           <ItemTemplate>
                               <span onclick="return confirm('Are you sure to delete?')">
                                   <asp:Button TID="lnkDelete" text="Delete" runat="server" />
                               </span>
                           </ItemTemplate>
                       </asp:TemplateField>

                   </Columns>
               </asp:GridView>
               </div>
           </div>


What I have tried:

how can i fixed html table margin with asp Gridview 
Posted
Updated 26-Aug-21 9:25am
Comments
Richard Deeming 26-Aug-21 5:30am    
Your question doesn't make any sense.

Remember, we cannot see your screen, access your computer, or read your mind. All we have to work with is what you type into the question box.

Click the green "Improve question" link and update your question to include a clear and complete description of the problem, along with the details of what you have tried and where you are stuck.

1 solution

Web forms have officially retired in .Net 5 & are no longer supported. Unless you're maintaining legacy code for your company, please try not to use them anymore. In your case, you're writing it up from scratch, hardly anything to do with legacy code. That being said, you're supposed to be familiar enough with CSS. Add a class to the CssClass property of your DataGrid, & play with table margins, cell spacing & stuffs like that in CSS. Also, DataGrid already comes with headers, footers, pagers & things like that, no need to use yet another table on top, which cannot possibly align with your DataGrid cells. Again, web forms are out, whose bugs no longer fixed by Microsoft. Learn Angular, React, Vue, or just anything that's still alive, preferably popular & hot.
 
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