Subscribe: Custom Server Controls
Added By: Feedage Forager Feedage Grade B rated
Language: English
application  create  data  departmentid  error  file  int null  label  new  null  row  runat server  server  system  web 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Custom Server Controls

All Forums

All Forums

Last Build Date: Tue, 27 Jun 2017 17:34:15 -0700


How to add cost per hotel and flight in duration cost table



How to get cost per hotel and flight then add it in duration cost table based on flight date automatically .


suppose i write flight date

26/07/2017 alexia 8days 04/08/2017 

it must automatically get cost from hotel price table and price from flight

then add it in duration cost table

so that

what query i write to get cost per hotel and flight when write flight date then insert it to duration cost table my database

     ProgramID int primary key not null, 
    ProgramName varchar(30)
     insert into program values(1,'Alexia'),(2,'Amon'),(3,'Sfinx') 
    CREATE TABLE ProgramDuration(
    DurationNo int primary key not null,
    programID int not null,
    Duration varchar(30) null
    insert into ProgramDurationvalues(1,1,'3 for Alexia'),(2,1,'5 for Alexia')
    CREATE TABLE DurationDetail(
     DurationNo int not null,
     [Days]  varchar(20) not null, 
    HotelID int null,
     FlightID int null

     insert into DurationDetail values (2,'Day1',1,'amsterdam to luxor','airport to hotel'), (2,'Day2',1,null,'AbuSimple musuem'), 
     (2,'Day5',1,'Luxor to amsterdam') 
    CREATE TABLE DurationCost(
    DurationNo int not null,
    [Date] date not null,
    Hote_cost numeric(18,0) null,
    Flight_cost numeric(18,0) null,
    Transfer_cost numeric(18,0) null
    insert into DurationCostvalues(
    CREATE TABLE [dbo].[FlightData](
        [FlighID] [nvarchar](50) NOT NULL,
        [FlightNo] [nvarchar](50) NOT NULL,
        [FlightDate] [datetime] NULL,
        [FlightTypeID] [int] NULL,
        [AirLine] [nvarchar](50) NULL,
        [Arrival] [time](7) NULL,
        [Departure] [time](7) NULL,
        [Price] [money] NULL,
        [Active] [bit] NULL
      insert into FlightData values (1,'ms300',1,'egyptairline','6','10',200,1)

    CREATE TABLE [dbo].[FlightRoute](
        [FlightTypeID] [int] NOT NULL,
        [FlightFrom] [nvarchar](max) NULL,
        [FlightTo] [nvarchar](max) NULL,
        [Active] [bit] NULL,
        [FlightRouteWay] [nvarchar](max) NULL,
    insert into FlightRoute values (1,'amsterdam','cairo',1,amsterdam to cairo), (2,'cairo','amsterdam',1,cairo to amsterdam)
    CREATE TABLE [dbo].[Hotel](
        [ProductID] [int] NOT NULL,
        [ProductName] [nvarchar](50) NULL,

     insert into Hotel values (1,'Hilton'), (2,'Movenpick')

    CREATE TABLE [dbo].[HotelPrice](
        [ProductPriceID] [int] NOT NULL,
        [ProductID] [int] NULL,
        [FromDate] [datetime] NULL,
        [ToDate] [datetime] NULL,
        [HotelPrice] [numeric](18, 0) NULL,
insert into HotelPrice values (1,1,01/07/2017,01-09-2017,20$), (2,1,02-09-2017,02-11-2017,30) 


Pass Html Table Multiple Rows to Controller



I need to create a form with several controls such as textbox and DateTime then by entering data and press add button, I need to add several records , the data will be added to l Html table, at the end, if I press submit, It will pass the data to the database (Controller).  I need to perform CRUD on HTML table before passing its values to the controller. 

I tried with 

but it is not working 

I have seen that in as an example. 

any IDEA? 



Populate data from SQL Serve in grid like table


I have a table with 54 columns; the first column is ID, the second column is short description and the rest of the 52 columns are bit type of data. How do I fill this grid based on the bit value in the database?

Screen flickers when click on a gridview page number


Why does my screen flicker when click on a gridview page number? What do I need to do to stop doing it?

Cascading Dropdownlist & ViewModel


Hello, I have the following models: Department (as city), District and Store. Department has one to many Districts Districts has one to many Stores I'm constructing a view where I create a new Store and the user can choose the Department(city) and then the District dropdownlist updates instantly with the corresponding districts. For this I created this ViewModel: StoreIndexData public class StoreIndexData { public Store Stores { get; set; } public Department Departments { get; set; } } This is the Controller where I populate the dropdownlist for the Department: public IActionResult Create() { //Departaments List List Departmentlist = _context.Departments.ToList(); Departmentlist.Insert(0, new Department { DepartmentID = 0, DepartmentName = "Select" }); ViewBag.DepartmentList = new SelectList(Departmentlist, "DepartmentID", "DepartmentName"); return View(); } And this is the View: @model Application.Models.ApplicationviewModels.StoreIndexData


@Html.DropDownListFor(model => model.Stores.DistrictID, new SelectList(" "), "Select", new { @class = "form-control"})
And in the end of the view, this is my JS section: @section Scripts { This section calls this action: public JsonResult GetDistrictList(int DepartmentID) { List DistrictList = _context.Districts.Where(x => x.DepartmentID == DepartmentID).ToList(); return Json(DistrictList); } And that's it. When I run the application, well, the District dropdownlist don't populate  _Questions: Is it possible that I can't access this properties inside the JScript  "#DepartmentID"  like this since I'm using a viewmodel? Maybe I need to change it to something like "#Departments.DepartmentID"? Could this work using a ViewModel? I'm not adding the Department property inside the Store model because it would be irrelevant since it gets its Department thru the District. I saw in the example that I followed that they added this line ProxyCreationEnabled = false Inside the JsonResult action. I didn't add it because I don't know what it does and don't know the consecuences in my application if I add it. Thanks in advance for any help. Regards, _Update: I put a break point on this line: List DistrictList = _context.Districts.Where(x => x.DepartmentID == DepartmentID).ToList(); But the application did not stopped there when I used the Department dropdownlist that is[...]

How do I find the index of the a row in an object of arrays


Hello everyone, I have this model in angular js

$scope.model = {
                    blocks: [
                            block_id: 0,
                            title: "My block 1",
                            rows: [
                               row_id: 1,
                               name: "my name"
                               row_id: 2,
                               name: "my name 2"
                               row_id: 3,
                               name: "my name 3"
                            block_id: 1,
                            title: "My block 2",
                            rows: [
                               row_id: 4,
                               name: "my name 4"
                               row_id: 5,
                               name: "my name 5"
                               row_id: 6,
                               name: "my name 6"
                    selectedBlock: undefined,
                    selectedRow: undefined,


$scope.updateRowSelected = function (row) {
                    //var rowIndex = ??
                    //var blockIndex=??
                    //$scope.model.selectedBlock = ??
                    $scope.model.selectedRow = row;

I have the selected row. How could I use that selected row to trace back to the current block it belongs to? And how could I find the index of the selectedRow and index of the block that the rows belong to?


Read large binary file into byte array - File.ReadAllBytes throws 'System.OutOfMemoryException'


Running on Windows Server 2003, IIS 6.0, Visual Studio 2010, .Net Framework 3.5

The web service is throwing a "System.OutOfMemoryException" whenever it tries to read a file large binary file (> 80 Meg).

To make troubleshooting this issue easier, I have separated out the code into a simple web service with only one call
GetByteArrayFromFile which reads a file and returns a byte array.

It consistently throws the 'Out of Memory' exception with files larger than 80 Meg.

Are there any steps I can take to resolve this issue?

'Web Service Call
Imports System.Web.Services, System.Web.Services.Protocols, System.ComponentModel

  Namespace:="")> _
Public Class ProcSvcs   Inherits System.Web.Services.WebService

Public Function GetByteArrayFromFile(ByVal PathFName As String) As Byte()    
  Dim Content() As Byte = System.IO.File.ReadAllBytes(path:=PathFName)      
  Return Content    
Catch ex As Exception      
   Throw New Exception(ex.Message)    
End Try  
End Function

End Class




Hi Folks,

I am dealing with a MVC application and I am stuck with a System.StackOverFlowException.

I have done some research about this error and found that it usually happens with recursive functions calls.

But I think this is a different  one.

I got the error when this query runs.

Select pes.* from pes where pes.pesid in 
(SELECT pesemp.pesid FROM pesemp 
Left JOIN emp ON pesemp.empid = emp.empid 
Left JOIN pesempfco ON pesempfco.pesempid = pesemp.pesempid 
Left JOIN fco ON pesempfco.fcoid = fco.fcoid 
Left Join pesemptrb on pesemptrb.pesempid = pesemp.pesempid 
Left Join loctrb on pesemptrb.loctrbid = loctrb.loctrbid 
Where pesemp.fim is null and fco.fcoid <> 9 ) 
Order by pes.gra 

The table generate by the query has 113 records but when I limit the number of records to 111 it runs without errors. 

Select pes.* from pes where pes.pesid in 
(SELECT pesemp.pesid 
FROM pesemp 
Left JOIN emp ON pesemp.empid = emp.empid 
Left JOIN pesempfco ON pesempfco.pesempid = pesemp.pesempid 
Left JOIN fco ON pesempfco.fcoid = fco.fcoid 
Left Join pesemptrb on pesemptrb.pesempid = pesemp.pesempid 
Left Join loctrb on pesemptrb.loctrbid = loctrb.loctrbid 
Where pesemp.fim is null and fco.fcoid <> 9 ) 
Order by pes.gra 
Limit 111 

Any ideas?

file is already opened exclusively by another user, or you need permission to view its data.


 It is already opened exclusively by another user, or you need permission to view its data.

private void CreateDBFFile()
    string connection = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

    using (OleDbConnection dbconnection = new OleDbConnection(connection))
    using (OleDbCommand command = dbconnection.CreateCommand())

        command.CommandText = "CREATE TABLE Test (Id Integer, Changed Double, Name Text)";

My web.config file has connection string


I am trying to create a dbf file on my K drive. I keep getting an error on my dbConnection.Open() statement saying:

The Microsoft Jet database engine cannot open the file 'k:\temp1'. It is already opened exclusively by another user, or you need permission to view its data.

K:\ is not a mapped drive. I gave network service userName to temp1 folder by going under security tab. I also gave modify rights to the Network service. Still keep getting this error. I also tried to put the entire above code in console application, that didn't work either. I keep getting the same error.

Any help will be greatly appreciated.

Send Selected Data from Gridview into Email


Dears, I'm trying to Send Selected Data from Gridview into Email but not working fine  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
In code behind using System; using System.Collections.Generic; using System.Linq;[...]

Affiliate Link Application in ASP.NET Core


Hi, how can I track user SignUp via Affiliate Links on my ASP .NET Core Application? Is it possible to, say, "pre-populate" some Form Field with Friend's Code, when an anonymous user click the link, in order to ensure the Bonus for whom indicates their friend to my site)? Any tutorial on how to implement this kind of Feature? Thanks!

Sql to Excel or CSV file



How can I create an Excel or CSV file in from a SQL Query in a web application? 

I once did it from Access, but I can't figure how to do in SQL.

Thanks for your help

Here is how I did it with Access.

 Dim NewConnection As New OleDbConnection
        NewConnection.ConnectionString = ConfigurationManager.ConnectionStrings("MyConnection").ConnectionString

        'New sheet in Workbook
        Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Excel 8.0;DATABASE=c:\Bank\OutStanding" & Me.Session("ReconDate") & ".xls;HDR=NO;].[Sheet1] from [tblOutStandChecks]", NewConnection)


But how with SQL Server?

How to recrtict certain views from IP range


Hi there,

I have an MVC application  and only* should be accessible from anywhere. should be accessible from a certain IP range only.  The reason I put * is that there could be a parameter like id=xyz, etc and/or views. I'm using IIS 7.5.

Can I use IP Address and Domain Restrictions? I guess I need to put the restriction only on Views folder and not the entire application folder.


Trying to write out a CSV file from grid



I have this code, which worked in a different V2008 application, but I can't get it to work in a VS 2012.

I keep getting this error:

Unhandled exception at line 885, column 13 in http://localhost:54620/ScriptResource.axd?d=JnUc-DEDOM5KzzVKtsL1tbN7qxcIx7CN1opCpOv33U7F-wK8ALruioyuFyCNpOPWvw_oPtcM3rh1BtbhjFmQCPsvs4aharqJP10yz4s2uqnyq-vR7Vj-zNTu8p3TX6BatBKrExU9agTNWfRaEyygKoup6UooHYq1aw5hfRaeoguvmmlG26KVhL9OPAoBojbP0&t=5f9d5645

Here is code:

        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.csv")
        Response.Charset = ""
        Response.ContentType = "application/text"

        Dim sb As New StringBuilder()
        For k As Integer = 0 To GridView1.Columns.Count - 1
            'add separator
            sb.Append(GridView1.Columns(k).HeaderText + ","c)

        'append new line
        sb.Append(vbCr & vbLf)
        For i As Integer = 0 To GridView1.Rows.Count - 1
            For k As Integer = 0 To GridView1.Columns.Count - 1
                'add separator
                sb.Append(GridView1.Rows(i).Cells(k).Text + ","c)
            'append new line
            sb.Append(vbCr & vbLf)


Do you see why I keep getting the error?

    if (handler) {
            var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
            handler(this, eventArgs);
            errorHandled = eventArgs.get_errorHandled();
        if (error && !errorHandled) {
            throw error;
    function Sys$WebForms$PageRequestManager$_ensureUniqueIds(ids) {
        if (!ids) return ids;

 point of error is on the throw error line above?

Thank you for your time.

About data base security


We have been using 3 layers, we does not use entity framewrok, we use encript connection string with a DLL for the DAL, but now on MVC how is this issue manage, now we use entity framework for the DAL, We have 3 scenarios, development environment, testing and production.  We are worry about security.

How to retrieve data from web site



I need to get data (draw number, draw date, ball1, ball2, ball3, ball4, ball5 and ball6) from a web site ( I would like to make a service to check every week if there is a new draw then get this row and write it to a database. Hope u can help me.

Best Regards. 

Query string do not work in windows 2012 web server


One page to take query string value like below.

It works at Windows 2008 web server but once move to Windows 2012 web server, the value "London" never pass.

How to set up IIS in Windows 2012 web server make query sting working?

Listview DataBound - How to change a column color - Web using VB


In a Web application using VB the below code will change the color of a ROW in a listview.  How do I change a COLUMN color in the row without changing the complete row?

This code is in the DATABOUND section.

 Dim DComment = TryCast(e.Item.FindControl("dcomm"), Label)

            If DComment IsNot Nothing AndAlso DComment.Text = "ABC" Then
                Dim row = CType(e.Item.FindControl("row"), HtmlTableRow)
                row.Attributes.Add("style", "color: red")
            End If

WebAPI OWIN Self-Hosted Problem



I'm trying to develop a WebAPI that will be self-hosted using OWIN, that will be running within a Windows service.  For those interested, we chose this deployment for easier installation at our customers sites.  This is the first time I'm trying to implement a self-hosted solution.

I was getting the following type of error:

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:9000/api/HelloWorld'.","MessageDetail":"No type was found that matches the controller named 'HelloWorld'."}

So, I thought lets make a simpler project with a simple console application.  But, I'm getting the same error.

I'm currently using Visual Studio 2017, .Net Framework 4.6.2, Microsoft.AspNet.WebApi.OwinSelfHost(and dependent NuGet packages).

Here's the code, that I'm using for testing:

using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Web.Http;

namespace FiloptoServer
    class Program
        public static void Main(string[] args)

        public class StartOwin
            public void Configuration(IAppBuilder appBuilder)
                var config = new HttpConfiguration();
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }

        public class HelloWorldController : ApiController
            public string Get()
                return "Hello, World!";

Any help would be appreciated.

not able to log in


Hi ,

I am new in mvc. I created one application in mvc C# with Mysql and deploy on test server. It was working fine.

after few days I added two field in database table and and same field I added in C# class. I tested it working fine.

But after published and deploy on test server, but its giving me error when try to login into login page.

Please help.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 4 44 45 46 47 48 49 50 51 52
1 Abandon Rigs