Designing custom gridviews using CSS in an ASP.NET application with Bootstrap

Hey there, I'm currently working on a post system using GRIDVIEW in ASP.NET/BOOTSTRAP. Since GRIDVIEW is basically a table, I am using templatefild and itemtemplate with table td and tr to make it resemble a BLOG! Everything is going well so far, I have managed to arrange it in the order I want (title, date, abstract, link to view the whole post, author). However, my goal is to apply CSS to these items to achieve a design like this: HOW I WANT

By applying the bootstrap classes, I can achieve a design like this: WITH THE BOOTSTRAP

As you can see, none of these options are exactly what I am looking for. Therefore, I attempted to create my own CSS style, but unfortunately, it doesn't seem to work. I created a class with my name, wrote the CSS code, applied the COLOR property, but the font color does not change. While bootstrap classes work perfectly fine, mine do not! Just a reminder, I am using WEBFORM + MASTER PAGE setup, where the master page contains a fluid container, a row, a column, and a contentplaceholder. Inside the contentplaceholder, there is a gridview with columns, templatefield, item template, table, tr, and td! I have tried applying CSS directly to the GRIDVIEW, but it is not reflecting. Here are some examples:

Master Page Code:

      <!-- CONTENT -->
    <div class="container-fluid bg-page">
        <div class="row">
            <div class="col-lg-8">

                <asp:ContentPlaceHolder ID="content" runat="server">
                </asp:ContentPlaceHolder>

            </div>

Page Code within Content Placeholder:

     <div class="container-fluid bg-page" id="content">
    <div class="row">
        <div class="col-lg-12">
            <asp:GridView ID="gdv_posts" runat="server"  ShowHeader="false" CssClass="table table-striped" GridLines="None" AutoGenerateColumns="false" PageSize="5" OnRowCommand="gdv_posts_RowCommand" AllowPaging="True" OnPageIndexChanging="gdv_posts_PageIndexChanging">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <table >
                                <tr >
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "title")%>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "date")%>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "description")%>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <asp:Button ID="btn_view" runat="server" Text="View" class="btn btn-link nav-link" CommandName="View" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "id")%>' />
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <%# DataBinder.Eval(Container.DataItem, "author")%>
                                    </td>
                                </tr>
                            </table>

                        </ItemTemplate>
                    </asp:TemplateField>

CSS Code:

.posts{
    color: aqua!important;

}

.posts table{
    color: aqua !important;
}

.posts td{
    color: aqua !important;
}

.posts tr{
    color:aqua !important;
}

Answer №1

If you're looking to implement a responsive design with Bootstrap, using a GridView may not be the best approach. Consider using a ListView instead. While there are resources available for using Bootstrap with a GridView, it may be more straightforward to utilize the ListView as it allows for the incorporation of responsive Bootstrap table markup directly into its template.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript array with more than 4 elements

I am working on a program where I have created an array and now want to display all the words that contain more than 4 letters. Check out my code snippet below: function oppC(){ var ord = ["Apple", "Two", "Yesterday", "mother", "lol", "car", "co ...

How can I connect the box using the Interactive Picture jQuery tool?

When using the Interactive picture jQuery, I have the following code snippet within my document: jQuery(document).ready(function(){ $( "#iPicture6" ).iPicture({ animation: true, animationBg: "bgblack", animationType: "ltr-slide ...

MUI version 5 - Keep styling separate from component files

Seeking to segregate styling from component File in MUI v5. In the past, I accomplished this in v4 by utilizing makeStyles as shown below: Page.style.js: import { makeStyles } from "@material-ui/core"; export const useStyles = makeStyles({ ro ...

The upper section of the pop-up modal is not fully visible when the screen size is decreased

My modal is experiencing an issue where the top part gets cut off when the screen is reduced, disappearing under the bookmarks and address bar. I attempted a solution mentioned in this resource by setting the top and bottom to 0, but it did not resolve the ...

What is the best way to align a jQuery Cycle 2 Slider in the middle of the

Having some trouble centering a jQuery Cycle 2 Slider on my page. You can see the slider here. I've attempted multiple methods to center it, but none have been successful. Check out the HTML code: <div class="slider"> <div id=outside> ...

Is it possible to override CSS classes in Ionic without using app.scss?

I'm currently working on designing a dark theme for my ionic application by watching this tutorial. It's been effective for most of the classes, however, I've encountered some CSS classes that only respond to overrides in app.scss. If I try ...

Steps for automating the process of opening a link in a new tab using Selenium UI test automation in C

Currently, I am in the process of creating selenium UI tests. My goal is to open a link in a new tab after clicking on it. Although I attempted to achieve this using the code below, I wasn't successful. Actions action = new Actions(WebDriver); action ...

When parsing a DateTimeOffset object, it is necessary to include timezone data

My current challenge involves validating data obtained from an API endpoint where users must input a DateTimeOffset. To address this issue, I have developed my own JsonConverter implementation to ensure the DateTimeOffset is in the correct format. Despite ...

Struggling with aligning and floating links to the right while crafting a custom navigation bar

I'm in the process of crafting a custom navigation bar for my website, with the intention of having my name prominently displayed on the far left while the links float to the far right. I've utilized CSS to style everything within the nav section ...

Erase embedded frame from a Google Sheets document

Is there a way for me to customize the frame and replace it with my own design? Click here to view the Google Sheet embedded frame ...

Is it feasible to make Twitter's Typeahead plugin have an initial slide down or fade in effect?

Does anyone have an easy way to make the dropdown from Twitter's typeahead jQuery plugin initially slide down or fade in? I'm trying to animate the size of the dropdown menu when it adjusts, but even a simple fade or slide in would be fine. I pre ...

What is the best way to prevent card-group from wrapping on smaller screens?

What is the best way to ensure that cards in a card-group stay adjacent to each other on smaller screens? Currently, they are grouped together on larger screens but appear separated on smaller screens. I am currently hiding the additional cards on smaller ...

Ways to calculate outcome

I'm fairly new to PHP and have run into an issue regarding displaying the number of results. For example, showing 'There are 200 results'. Thank you in advance. Below is the code I am working with: try { $bdd = new PDO("mysql:host=localho ...

Methods for performing a task on a class automatically, while ensuring it is only executed one time

My goal is to create a system where all classes derived from a base class automatically have a specific operation performed when they are loaded, but only once during the program's execution. I want to simplify the process for the person creating the ...

Bootstrap Thumbnail Grid - dynamic loading with ajax

Situation: I am facing a challenge where I have a view displaying countries in a twitter bootstrap thumbnail grid. Upon clicking an image, the intention is to dynamically show cities related to that particular country within the same grid on the screen. T ...

Using Sessionid in Selenium Webdriver in C# application

Why is SessionID important in Selenium Webdriver? Imagine a situation where 5 browsers are opened, each with its own sessionid. Is it possible to use these sessionids to close their respective browsers? If yes, how can this be achieved in C#? ...

Floating footers with centered content - they remain aligned in the center even when zoomed out

Behold my unique and straightforward footer design (100% zoom above, 70% zoom below) : To keep things simple, I aimed to center content with a single div having a fixed width and margin: 0 auto, all while maintaining the same color for the outer footer la ...

Managing dates in Visual Studio C# with Microsoft SQL Server databases

I am currently exploring the most efficient and seamless method to extract dates from the database and accurately parse/cast them within my DataAccessLayer (DAL) methods. The columns in my database are all of type date. In particular, I have defined this ...

Using jQuery for client-side validation when the user clicks a button in an ASP.NET application

My goal is to implement field validation on button click using Jquery, but I'm facing an issue where it seems like the code behind event and the jQuery event are executing simultaneously. (UPDATED) <asp:Button ID="btnsave" runat="server" ClientI ...

Creating a perfect design with Font Awesome 5 SVG icons and vertically aligned text at the top

Check out my code example on CodePen, view source. I'm looking for a way to align an icon and text vertically without using JavaScript. I want to maintain the li element's line-height and other styles. Any suggestions? ...