gridview is not displaying in my page.In data table data is coming but grid view is not displaying.

code behind

   private void BindProducts()
              using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["kernelCS"].ConnectionString))
                // using (SqlCommand cmd = new SqlCommand("sp_FillData", con))

                using (SqlCommand cmd1 = new SqlCommand("select * from tbl_price", con))
                    //  cmd.CommandType = CommandType.StoredProcedure;
                    if (con.State != System.Data.ConnectionState.Open)
                    DataTable dt1 = new DataTable();
                    gridviewProducts.DataSource = dt1;



    aspx code
  <asp:GridView runat="server" ID="gridviewProducts" AutoGenerateColumns="false"></asp:GridView>

I am using ServiceStack (self hosted) with Razor.

I have an issue trying to add System.Core to the namespaces in the web.config file.

Specifically, I get a compilation error if I include System.Core in the web.config.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'Core' does not exist in the namespace 'System' (are you missing an assembly reference?)

Source Error:

Line 12: using System; Line 13: using System.Collections.Generic; Line 14: using System.Core; Line 15: using System.Data; Line 16: using System.IO;

Extract of Web.config file:

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
    <add namespace="System" />
    <add namespace="System.Core" /> **-> THIS GIVES AN ERROR**
    <add namespace="System.Data" />
    <add namespace="System.Linq" />
    <add namespace="ServiceStack" />
    <add namespace="ServiceStack.Html" />
    <add namespace="ServiceStack.Razor" />
    <add namespace="ServiceStack.Text" />
    <add namespace="ServiceStack.OrmLite" />
    <add namespace="Classifieds" />
    <add namespace="Classifieds.ServiceModel" />
    <add namespace="Classifieds.ServiceInterface" />

Initially, the dropdown values are loaded from the model, now it needs to be loaded "static values". so I'm using the below type to load the dropdown for this, I can't able to add the CSS-class. Need advice

 @Html.DropDownList("RoundOffInterval", new List<SelectListItem>
     new SelectListItem{ Text="Select Roundoff Interval",Value=""},
     new SelectListItem{ Text="5",Value = "5" },
     new SelectListItem{ Text="10", Value = "10" },
     new SelectListItem{ Text="15", Value = "15" },
     new SelectListItem{ Text="20", Value = "20" },
     new SelectListItem{ Text="30", Value = "30" }

Before I used the below type:

@Html.DropDownListFor(m => m.RoundoffInterval, new SelectList(Model.RoundoffIntervalList, "Id", "Name"), "Select Roundoff Interval ", new { id = "RoundoffInterval", name = "RoundoffInterval", @class = "select2_demo_4 form-control" })

I have MVC Razor project with service libraries as separate project. For Dependency Injection, I have used Unity Framework. Everything works fine except when I do any change in Razor view, the Unity is throwing the error "The current type, IUserService, is an interface and cannot be constructed. Are you missing a type mapping? "

Only when I recompile the web project or Build the Service project it works again. It has become tedious for development because for every change in cshtml file, I need to recompile the MVC project. Happens for just adding text also.

How I will fix this issue?

I have an existing database for which I have created a edmx file. Now I am trying to connect the default AccountController to this database and implement login/registration functionalities but it doesnt work.

Things I tried -

I tried changing the context in the IdentityModels.cs.

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
        public ApplicationDbContext()
            : base("MyConnection")

Error - The entity type ApplicationUser is not part of the model for the current context.

Then, I tried this

    public partial class myEntities : IdentityDbContext<ApplicationUser>
            public myEntities ()
                : base("name=myEntities ")
    ... }

It dint work either.

  1. Can someone help me with the steps involved in connecting my current database to the default account controller.
  2. Should I create the tables in the database myself or will it be created ?

Thanks in advance.

I'm working on a portlet for a dashboard, and I was able to successfully design it so that it retrieves data from a database, and display the information, while refreshing at a time interval chosen by the user (DropDownList2).

What I now want it to do is to refresh ONLY if there's a change in the database. So I tried the following (and yes, I was able to establish a working connection. 'com' is a SqlCommand. AmountSold is a column from my database table):

SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();

DataTable ChartData = ds.Tables[0];

//storing total rows count to loop on each Record   
string YPointMember = Convert.ToString(ChartData.Rows[1]["AmountSold"]);

SqlDependency dep = new SqlDependency(com);

if (dep.HasChanges == true)
    HtmlMeta metaKey = new HtmlMeta();
    metaKey.HttpEquiv = "Refresh";
    metaKey.Content = DropDownList2.SelectedValue;

Unfortunately, the portlet never refreshes at all, regardless of whether or not there is a database change. Any solution/alternative to this?

i would like implement richtexteditor into mvc 6 rc1 application. on the link i see i need to update the web.config. as i understand mvc 6 doesnt support web.config i would like to ask if there is another way to do this work?

or i need to search for another editor to use in my application?

thank you


I am in need of some advice. I am new to asynchronous web applications and I am wondering what the best course of action would be.

I have a dropdown that displays a list of individuals which is populated by a web service call and an ASP AutoCompleteExtender. Once an individual is selected, I need to update two dropdowns (Department and Location) using the selected individual.

The dropdowns are populated with data from a database using a SqlDataSource, so the items in the list are static. I will need to call Active Directory to get the Department and Location of the individual and set the selected items accordingly.

I know this can be accomplished using a Postback, however I do not want the page to be reloaded after the individual is selected. Any suggestions for how to accomplish this task without a Postback?

I´m working on ASP .NET MVC 5 application and now I´m implementing newsletter functionality. I have master (parent view) with all stuff and on this view there is also box with input field for email and submit button. After click on this button, controller method insert this e-mail to subscribers tab. I´ve got GET/POST method and PartialView for this Newsletter (all newsletter´s code is in separate area). Everything works fine, there is only one problem. On master page I have another submit button (for submitting search string) so everytime after submitting search string, code also submit newsletter form. Is there any solution to separate this two submit buttons and way to not refresh whole page after submit newsletter (PartialView) form?

Here is my Newsletter PartialView called _SignIn

@using (Html.BeginForm()) 


<div class="form-horizontal">
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model =>, htmlAttributes: new {@class = "control-label col-md-12", style="text-align: left; padding-left: 30px;"})
        <div class="col-md-12" align="center">
            @Html.EditorFor(model =>, new {htmlAttributes = new {@class = "form-control"}})
            @Html.ValidationMessageFor(model =>, "", new {@class = "text-danger"})

    <div class="form-group">
        @Html.LabelFor(model => model.NewsletterType, htmlAttributes: new { @class = "control-label col-md-12", style = "text-align: left; padding-left: 30px;" })
        <br />
        <div class="col-md-12" align="center">
            @Html.EnumDropDownListFor(model => model.NewsletterType, new { @class = "form-control" })
            @Html.ValidationMessageFor(model => model.NewsletterType, "", new { @class = "text-danger" })

    <div class="form-group">
        <div class="col-md-offset-4 col-md-10" style="padding-bottom: 10px;">
            <input type="submit" value="Prihlásiť" class="btn btn-success" />

Thank you for any response!

I'm building a page and need to add a business locator with a map. I'm always looking for the same business type (pharmacies in this case), so my locations will not be stored in my database. I just want the user to enter a zip and a radius, and I'll show them all of the pharmacies in their area.

The Google api keeps popping up in my research, I even generated my MapKey. Is there an easier or better way to accomplish what I'm after? Suggestions?

My environment is ASP.NET, VB, SQL Server 2012

In; What can I do to make my meta tags all be on separate lines? Currently it forms one long line. If I add a simple br tag, the tag shows in the code

<title>About Us</title>
<meta name="description" content="This is the about us meta description" />
<meta name="keywords" content="This is the about us Meta Keywords" />

The error is:

error CS0246: The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?)

It occurs on the rendering of a template file begining with

@using Google.Apis.Requests
@using Google.Apis.Calendar.v3.Data;

@model Google.Apis.Calendar.v3.Data.Events

It appeared after I changed Google.Client.Api assemblies from 1.9.3 to 1.10 using Nuget package. All the necessary Google assemblies are referenced in the project.

Strange thing is that VS intellisense perfectly sees the namespace and can open the Events class. And all the c# code compiles normally.

I have a FAQ page that has a jQuery Accordion and a repeater control inside the accordion that will display various questions and answers. The FAQ page has a master page called LaunchPage.Master.

Below is my LaunchPage.Master Code


<head runat="server">
  <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport' />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" charset="utf-8" />
  <!-- Bootstrap 3.3.4 -->
  <link href="content/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  <link href="content/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
  <!-- Theme style -->
  <link href="content/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
  <asp:ContentPlaceHolder ID="HeadContent" runat="server">
  <asp:ContentPlaceHolder ID="head" runat="server">
  <script defer="defer" type="text/javascript" src="Content/js/jQuery/jQuery_1_7_2.min.js"></script>

<body class="skin-blue-light sidebar-mini">
  <div class="wrapper">
    <header class="main-header">
      <!-- Logo -->
      <a href="#" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"> </span>
        <!-- logo for regular state and mobile devices -->
      <!-- Header Navbar: style can be found in header.less -->
      <nav class="navbar navbar-static-top" role="navigation">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button" title="Toggle Full Frame"></a>
        <!-- Navbar Right Menu -->
        <div class="navbar-custom-menu">
          <ul class="nav navbar-nav">
            <li class="dropdown user user-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <span class="hidden-xs">
                                            <asp:Label ID="lftSideLabel" runat="server" CssClass="info" />
          <ul class="nav navbar-nav">
            <li class="dropdown notifications-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="SettingsIcon" title="Settings" runat="server">
                <i class="glyphicon glyphicon-cog" title="Settings"></i>
              <ul class="dropdown-menu">
                <li class="header">Settings</li>
                  <!-- inner menu: contains the actual data -->
                  <ul class="menu">
                    <li id="nUser" runat="server">
                      <a href="Register.aspx" id="RegisterOption">
                        <i class="fa fa-user-plus text-aqua"></i>Create New User
                    <li id="cPassword" runat="server">
                      <a href="changepassword.aspx" id="ChangePasswordOption">
                        <i class="fa fa-pencil text-red"></i>Change Password
              <ul class="nav navbar-nav">
                <li class="dropdown user user-menu">
                  <a href="LogoutPage.aspx" class="dropdown-toggle" title="Logout" ID="Signout">
                    <i class="glyphicon glyphicon-log-out" title="Logout"></i>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
      <!-- sidebar: style can be found in sidebar.less -->
      <section class="sidebar">
        <!-- Sidebar user panel -->
        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu">
      <!-- /.sidebar -->
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Main content -->
      <section class="content">
        <form id="form1" runat="server">
          <asp:ScriptManager ID="ScriptManager1" runat="server">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
      <!-- /.content -->
    <!-- /.content-wrapper -->
    <footer class="main-footer">
  <!-- ./wrapper -->
<script defer="defer" type="text/javascript">
  //Auto redirect to login page
  function SessionExpireAlert(a) {
    setTimeout(function() {
      window.location = "Login.aspx"
    }, a)
<script defer="defer" type="text/javascript">
  $("[id*=Signout]").live("click", function() {
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "Landing.aspx/LogoutIcon",
      data: "{}",
      dataType: "json",
      success: function(a) {},
      error: function(a) {
<script defer="defer" type="text/javascript">
  $(document).ready(function() {
    $("#tabs li:first").attr("id", "current");
    $("#content #tab1").fadeIn();
    $("#tabs a").click(function(a) {
      "current" != $(this).closest("li").attr("id") && ($("#content").find("[id^='tab']").hide(), $("#tabs li").attr("id", ""), $(this).parent().attr("id", "current"), $("#" + $(this).attr("name")).fadeIn())
<!-- jQuery 2.1.4 -->
<script defer="defer" src="Content/js/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.2 JS -->
<script defer="defer" src="Content/js/bootstrap.min.js" type="text/javascript"></script>
<!-- AdminLTE App -->
<script defer="defer" src="Content/js/AdminApp/app.min.js" type="text/javascript"></script>


This is my FAQ.aspx Code

<%@ Page Title="" Language="C#" MasterPageFile="~/LaunchPage.master" AutoEventWireup="true" CodeFile="FAQ.aspx.cs" Inherits="FAQ" %>

  <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

      <link href="" rel="stylesheet" type="text/css">
      <script type="text/javascript" src=""></script>
      <script type="text/javascript" src=""></script>
        $(document).ready(function() {
            active: false,
            collapsible: true,
            heightStyle: "content",
            alwaysOpen: false
          <div class="wrapper row-offcanvas row-offcanvas-left">
            <section class="content-header">
            <div id="dvAccordian" style="width: 99%" runat="server">
              <asp:Repeater ID="rptFAQ" runat="server">
                  <div class="s_panel" style="font-family: 'Roboto'; font-size: small">
                                        <a href="#" class="lblFontSmall" data-content="Tool tip"><%# Eval("Question") %></a>
                        <small><span class="lblFontSmall"><%# Eval("Answer") %></span></small>

            <br />
            <br />

When I view the FAQ Page, I am not getting the accordions. Rather I am getting only the text. The jQueryUI.js and .CSS links are working fine. I tried to change my script and css link reference to my master page under the head as well as in my FAQ page too. However i am getting the same output as text instead of accordions.

I tried to troubleshoot based on the response provided in these links, however nothing worked.

jQuery Accordion not working

jQuery accordion its not working

jQuery accordion() not working

I am not able to find the root cause of the issue. When I inspect the code, the jQuery is not getting detected and loaded to the dvAccordion control. Any help is highly appreciated.

I tried to ask this question but some users thought it was a duplicate and closed the question. I explained it in a comment but in any case, I wrote an extension method in C# and it will appear in an answer.

I really don't know how to hide all legend years except last (2014). I need when the page opens , to show only 2014 year, not all years.

When user redirected on this page, he should see only 2014 ( by default) . I don't know how to hide other values. If he wants to see values for other years - he just click on other legend values and then chart visualized values for selected year(s)

This is my code in Razor engine Mvc App :

                              .HtmlAttributes(new { style = "height: 650px;" })
                              .Legend(leg => leg.Position(ChartLegendPosition.Top))
                              .Legend(leg => leg.Position(ChartLegendPosition.Top))
                              .ChartArea(area => area.Background("transparent"))
                              .SeriesDefaults(l => l.Column().Visible(false))
                              .Series(series =>
                                  foreach (var def in Model.Series)
                                      string curVal = Convert.ToString(DateTime.Now.Year - 1);

                                      if (def.Years != curVal)


                              .CategoryAxis(axis => axis.Categories(Model.Categories).Labels(label => label.Rotation(-90)))
                              .ValueAxis(axis => axis.Numeric().Labels(labels => labels.Format("{0:P}")))
                              .SeriesColors("red", "blue", "yellow", "#006634", "#c72e15")

                              .Tooltip(tooltip => tooltip.Visible(true).Template("#= category # <br/>  #= # <br/>   (#= kendo.format('{0:P}',value )#) "))
                              .SeriesColors("#FC8701", "#1500D7", "#00D72F", "#D7AC00", "#FC1F01", "#8F0774", "#05D5FA", "#FCF001", "#01FC1F", "#84491B")
                              .Events(ev => ev.AxisLabelClick("onAxisLabelClick")


        <script type="text/javascript">

            function dataYearLoad() {
                var chart = $("#chart").data("kendoChart");
                chart.options.series["Years"].visible = false;

                for (var i = 0, length = series.length; i < length; i++) {
                    series[i].stack = stack;
                 //   series[i].visible = (types.indexOf(series[i].type) !== -1);
                    series[i].visibleInLegend = false;


I've got radio buttons in MVC Razor like this

<td style="min-width:110px" align="center"><label for="naraName">@listOfNames[i]</label></td>
<td style="min-width:110px" align="center"><input type="radio" name="naraName" value=@listOfNames[i] /></td>

which in HTML look like this: enter image description here

But problem is, that this radio button return incomplete string. It should return "na na na nara" but only return "na" like this

enter image description here

Any ideas, how to fix this?

I'm using a simple timer with this code as a backend

 protected void Timer1_Tick(object sender, EventArgs e)
        int seconds = int.Parse(Label1.Text);
        if (seconds > 0)
            Label1.Text = (seconds - 1).ToString();
            Timer1.Enabled = false;


The timer is grouped along with a Label and a Button inside a UpdatePanel in my front-end.

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <asp:Image ID="RedBox" runat="server" ImageUrl="~/images/redbox.png" Visible="false" CssClass="redbox1" ClientIDMode="Static" />
                        <asp:Button ID="schlbtn1" runat="server" Text="Go To Lectures" CssClass="btn btn-lg btn-success btn-block" OnClick="schlbtn1_Click" Visible="true" ForeColor="Black" ViewStateMode="Enabled" ClientIDMode="Static" />
                        <asp:Label ID="Label1" runat="server" Visible="false" CssClass="timerlbl" Font-Size="XX-Large">60</asp:Label>
                        <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" Enabled="false">

I'm looking for a way to make the timer NOT to reset on every page refresh. I need the timer to still count down until it reach 0 even if the client is not on the same page. I tried Sleep methods but think this is not the solution. Please make any kind of suggestions.

I am building MVC based web application. I have used form authentication.

My requirement is like I have default 20 Min as session expiry time. I don't want to extend it for more. But our data operator says that when they fills some forms it takes more than 20 Min to fill in single form (off course very large/long forms) and after they completes the form filling they clicks on submit and page goes to Login page due to session expires while filling the form.

So my question is like do we have some background identification method that identifies that session will expire in few minutes and send data operator a message box like Your session will expire in 2 minutes, click confirm to create new session.

When they clicks on the Confirm we can send ajax call to create new session for that operator so when they submits a form their form will save correctly.

My application is built using ASP.NET and angularjs. It is completely working fine in Chrome but in Internet explorer it keeps on loading.

I'm using in-proc session state in my application & just change in-proc to custom.

After changing session state, some place I'm encounter with 500 internal error.

Here is my web.config entery

Can somebody can help me why this is happening ?

I am running into a logical problem.My Trigger is:

  create trigger Points
  on AspNetUsers
  after insert, update
  if exists (select PostedBy 
         from Posts i join AspNetUsers m
         on i.PostedBy = m.Id)
         update AspNetUsers set User_points = User_points + 3 
         where exists (select PostedBy from Posts i 
          join AspNetUsers m
          on i.PostedBy = m.Id

I dont know whether i am doing it right or not.

Two tables: AspNetUsers table with User_points column and Id Column as primary key

Posts table with PostId as primary key and PostedBy as foreign key referencing the AspNetUsers table.

Now, i want to compare PostedBy with Id column and if they both are same then update the User_Points column with +3 on every single message he posted.

Now, problem is: 1> how to check for if there is a new Posts in post table. Something condition which checks for every insert in Posts table. I have tried it:

 update AspNetUsers set User_points = Count(Posts.Message) + 3

but it is giving error. cant fetch Posts.Message out of scope.Please tell me how to do it. thanks in advance