I have used your technique for responsive gridview but its only working for manually given data (same as you have given in example on https://www.aspsnippets.com/Articles/Bootstrap-Responsive-GridView-for-Mobile-Phone-Tablet-and-Desktop-display-in-ASPNet-using-jQuery.aspx but its not working when data is being fetched form database using stored procedure... Please help me out in this asap...i am frustrated with it. Thank you in advance
here is my code:
C# CODE:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string conn = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
SqlCommand com = new SqlCommand();
con.Open();
// Create a object of SqlCommand class
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "fetchgriddata";
com.Connection = con;
GridView1.EmptyDataText = "No Records Found";
GridView1.DataSource = com.ExecuteReader();
GridView1.DataBind();
//Attribute to show the Plus Minus Button.
GridView1.HeaderRow.Cells[0].Attributes["data-class"] = "expand";
//Attribute to hide column in Phone.
GridView1.HeaderRow.Cells[1].Attributes["data-hide"] = "phone";
GridView1.HeaderRow.Cells[2].Attributes["data-hide"] = "phone";
GridView1.HeaderRow.Cells[3].Attributes["data-hide"] = "phone";
GridView1.HeaderRow.Cells[4].Attributes["data-hide"] = "phone";
GridView1.HeaderRow.Cells[5].Attributes["data-hide"] = "phone";
GridView1.HeaderRow.Cells[6].Attributes["data-hide"] = "phone";
}
}
HTML CODE:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<script type="text/javascript">
$(function () {
$('[FName*=GridView1]').footable();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" CssClass="footable" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="FName" HeaderText="First Name" ItemStyle-Font-Italic="true"
ItemStyle-Font-Bold="true" ItemStyle-Font-Size="14px" HeaderStyle-Font-Size="17px" />
<asp:BoundField DataField="LName" HeaderText="Last Name" ItemStyle-Font-Bold="true"
ItemStyle-Font-Italic="true" ItemStyle-Font-Size="14px" HeaderStyle-Font-Size="17px" />
<asp:BoundField DataField="Email" HeaderText="Email" ItemStyle-Font-Bold="true" ItemStyle-Font-Size="14px"
ItemStyle-Font-Italic="true" HeaderStyle-Font-Size="17px" />
<asp:BoundField DataField="HAddress" HeaderText="Address" ItemStyle-Font-Bold="true"
ItemStyle-Font-Size="14px" HeaderStyle-Font-Size="17px" ItemStyle-Font-Italic="true" />
<asp:BoundField DataField="City" HeaderText="City" ItemStyle-Font-Bold="true" ItemStyle-Font-Size="14px"
HeaderStyle-Font-Size="17px" ItemStyle-Font-Italic="true" />
<asp:BoundField DataField="PhoneNo" HeaderText="Phone Number" ItemStyle-Font-Bold="true"
ItemStyle-Font-Size="14px" HeaderStyle-Font-Size="17px" ItemStyle-Font-Italic="true" />
<asp:BoundField DataField="CreatedOn" HeaderText="Date Applied" ItemStyle-Font-Bold="true"
ItemStyle-Font-Size="14px" HeaderStyle-Font-Size="17px" ItemStyle-Font-Italic="true" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>