I am working on a project in which I want to increase the space between the two columns and their respective fields .I also want to align one of my column named as detail to left hand side in a proper manner can any one tell me how to do it.Image in which i want to increase the space Here is my code :

<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="650px" AutoGenerateRows="False"
                        DataSourceID="SqlDataSource2" GridLines="None" Font-Bold="True" Font-Size="Medium">
                        <Fields>
                            <asp:BoundField DataField="categoryname" HeaderText="Category:" SortExpression="categoryname" />
                            <asp:BoundField DataField="subcatname" HeaderText="Subcategory:" SortExpression="subcatname" />
                            <asp:BoundField DataField="packageprice" HeaderText="Price:" SortExpression="packageprice" />
                            <asp:BoundField HeaderText="" DataField="detail" SortExpression="detail">

                            </asp:BoundField>
                        </Fields>
                    </asp:DetailsView>

I have used:

Request.Unvalidated.Form["valuefromcontrol"];

Because my control returns values in tags, i.e (<p> values </p>) etc. but it gives null values.

I have searched about it and found this Asp Unvalidated Input

But when I used the technique that is mentioned in above link it gives error in the given link the description of Unvalidated Method is used as

string var = Request.Unvalidated("valueofcontrol");

and

string var = Request.Unvalidated().Form["valueofcontrol"];

But when I tried to use these technique vs gives an error saying that Unvalidated cannot used as method.

What should I do for getting value without validation ?

for more better understanding I have used CKEDITOR as a control.

I have View where I create interview with greeting and details

Here is table

CREATE TABLE [dbo].[Interviews] (
[Interview_Id] INT            IDENTITY (1, 1) NOT NULL,
[Greeting]     NVARCHAR (MAX) NULL,
[Detail]       NVARCHAR (MAX) NULL,
[VacancyId]    INT            NULL,
PRIMARY KEY CLUSTERED ([Interview_Id] ASC),
CONSTRAINT [FK_Interviews_ToTable] FOREIGN KEY ([VacancyId]) REFERENCES [dbo].[Vacancies] ([VacancyId]) ON DELETE CASCADE

);

Here is my controller for this View

  // Страница ввода приветствия и описания вакансии
    [HttpGet]
    public ActionResult WelcomeScreen()
    {
        // Формируем список команд для передачи в представление
        SelectList teams = new SelectList(db.Vacancy, "VacancyId", "VacancyName");
        ViewBag.Teams = teams;

        return View();
    }


    //Заносим инфу о вакансии в таблицу
    [HttpPost]
    public ActionResult WelcomeScreen(Interview interview)
    {
        db.Interview.Add(interview);
        db.SaveChanges();
        //Int32 id = interview.Interview_Id;
        //TempData["id"] = id;

        return RedirectToAction("Index", "Questions", new { id = interview.Interview_Id });
    }

Here is my View

    @using (Html.BeginForm())
{
    <div class="outer-div">
        <div class="inner-div">
            <div class="right-welcome-div">
                <div class="right-grid-in-grid">

                    <div class="col-md-10">
                        @Html.DropDownListFor(model => model.Vacancy.VacancyId, ViewBag.Teams as SelectList, new { @class = "greeting" })
                        @Html.ValidationMessageFor(model => model.VacancyId, "", new { @class = "text-danger" })
                    </div>

                </div>
                <div class="main-left-div">

                    <div style="margin-left: 40px">
                        @Html.EditorFor(model => model.Greeting, new {htmlAttributes = new {@class = "greeting", data_bind = "textInput: Greeting", placeholder = "Приветствие", id="Greeting"}})
                    </div>

                    @Html.TextAreaFor(model => model.Detail, new { @class = "greeting2", data_bind = "textInput: Detail" })

                </div>
             </div>
            <div class="left-welcome-div">
                <div class="text-div" style="padding-top: 30px; word-break: break-all;">
                    <p style="font-size: 20px; margin-top: 20px; padding-left: 30px; padding-right: 40px; text-align: center;"><b><span data-bind="text: Greeting"/></b>
                    </p>
                    <p style="font-size: 20px; margin-top: 40px; padding-left: 30px; padding-right: 40px; text-align: center;"><span data-bind="text: Detail"/>
                    </p>
                </div>
                <div class="button-div" style="padding-top: 40px;">
                    <input  style="float: right; margin-right: 30px; margin-top: 20px; border-radius: 12px; width: 200px;" type="submit" value="Создать" class="btn btn-default" />
                    </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function ViewModel() {
            this.Greeting = ko.observable('');
            this.Detail = ko.observable('');
        };

        var vm = new ViewModel();
        ko.applyBindings(vm);

    </script>
}

When I click submit button it creates new empty row in Vacancies table.

I don't understand, why??

Why so?

I've read MSDN documentation of JsonRequestBehavior.AllowGet and many answers here at SO. I experimented and I am still confused.

I have the following action method. It works fine if I use POST method in my ajax call. It fails with status 404 (Resource not found) if I use GET method in my ajax call. So, the question is what exactly does the JsonRequestBehavior.AllowGet enum do in this Json method? The MSDN documentation says: AllowGet HTTP GET requests from the client are allowed. (https://msdn.microsoft.com/en-us/library/system.web.mvc.jsonrequestbehavior(v=vs.118).aspx), but then why does it fail when I use GET method in my ajax call? Changing the attribute from HttpPost to HttpGet does not help, it fails with either POST or GET method.

 [HttpPost]
    public JsonResult Create(Model m)
    {
        m.Ssn = "123-45-8999";
        m.FirstName = "Alan";
        m.LastName = "Chang";
        m.Id = 1000;
        return Json(m, JsonRequestBehavior.AllowGet);
    }

    public class Model
    {
       public int Id { get; set; }
       public string Ssn { get; set; }
       public string FirstName { get; set; }
       public string LastName { get; set; }
    }

Here is my jQuery ajax call:

    $(function () {
        console.log("hola");

        $("button").on("click", function () {
            $.ajax({
                method: "POST", //Try changing this to GET and see.
                url: "Home/Create",
                data: { Id: 123, Ssn: "585-78-9981", FirstName: "John", LastName: "Smith" }
            })
    .done(function (msg) {
        alert("Data Saved: " + msg);

        });

  });

    })

In Startup.Auth.cs

app.UseFacebookAuthentication(
   appId: "xxxxxx",
   appSecret: "xxxxxx");

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
    ClientId = "ssssss",
    ClientSecret = "sssss"
});

In my localhost both google and facebook external login are working but in my live site facebook is not. In my live site when a user clicks facebook login it will prompt for permission but it will just go back to Login, I think it's returning null

 public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
    var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
    if (loginInfo == null)
    {
        return RedirectToAction("Login");
    }

    // Sign in the user with this external login provider if the user already has a login
    var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
    switch (result)
    {
        case SignInStatus.Success:
            return RedirectToLocal(returnUrl);
        case SignInStatus.LockedOut:
            return View("Lockout");
        case SignInStatus.RequiresVerification:
            return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
        case SignInStatus.Failure:
        default:
            // If the user does not have an account, then prompt the user to create an account
            ViewBag.ReturnUrl = returnUrl;
            ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
            var viewModel = new ExternalLoginConfirmationViewModel
            {
                Email = loginInfo.Email
            };
            ViewBag.Title = "Register";

            return View("ExternalLoginConfirmation", viewModel);
    }
}

Any idea? My live site is not using ssl.

First this is an ASP.net webform project.

I have a pretty simple loop using EntityFrameWork

foreach(student s in classes)
{
    connector.student.Add(s);
}

Here, connector is the object used to access EntityFramework methods. But When tha query executes, I get the following error :

An entity object cannot be referenced by multiple instances of IEntityChangeTracker.

What could be causing that error ?

I read Entity Framework "An entity object cannot be referenced by multiple instances of IEntityChangeTracker"

I made sure connector was the only entityframework object used to perform my CRUD operations. I still get the error. BUT connector is used on the Page_Load event WITHOUT any issue.

ps : I did not post too much code because this is new to me. Let me know if you need to see some more code.

When creating a web method in an ASMX file of a C# web application, the associated WSDL is of this format:

<Envelope>
  <Header/>
  <Body>
    <WebMethodName>
      <WebMethodArgumentName>
        <WebMethodArgumentType>

I need to have it like this:

<Envelope>
  <Header/>
  <Body>
    <WebMethodName>
      <WebMethodArgumentType>

Or like this:

<Envelope>
  <Header/>
  <Body>
    <WebMethodArgumentName>
      <WebMethodArgumentType>

This is because the client sends the request in that format, so I need to control the name of the outer tag, and the only way I can think of is by changing the name of the web method or the web method argument, but in order to do that, I need to have only one of those tags.

How can I accomplish this?

Thanks in advanced, guys!

I'm currently trying to take an ASP.NET Web Forms project written in Visual Studio 2013 on Windows 7 and move it to an IIS 6 site on Windows Server 2008, but I'm having trouble figuring out how to do it.

I've tried simply copying the project file from the Visual Studio directory to the one used by the site, but this causes important navigation commands to not work properly.

I've also tried using Visual Studio's Publish tool, but I haven't been able to get the Web Deploy, Web Deploy Package, FTP, or File System publish methods to work properly. I'm not certain which, if any, of these to use.

If anyone knows a method that could accomplish this, please let me know.

This question already has an answer here:

I'm trying to parse a markdown-string:

My model is something like this:

class Model
{
    public string MethodName {get;set;}
    public string CodeBlock {get;set;}
}

json-data of my model:

{
    "MethodName":"Test",
    "CodeBlock":"int[] s = new List<int>().ToArray();"
}

my template looks like this:

string template = @"# @Model.MethodName

```csharp
@Model.CodeBlock
```";

I'm parsing with:

string generatedCode = Razor.Parse(template, model);

the parsed output now looks like:

# Test

```csharp
int[] s = new List&lt;int&gt;().ToArray();
```

So the engine parses < to &lt; and > to &gt; (instead of leaving it with those brackets), which is not correct displayed in a markdown-editor. What I really want to get is:

# Test

```csharp
int[] s = new List<int>().ToArray();
```

Any idea what I could do to get this?

With Asp.Net it was easy to see the code generated by the Razor View Engine: Add a compile error and the error page will give access to the source of the Razor Page.

This changed with Asp.Net Core, which I read somewhere creates the code in memory and does not allow access to that code easily.

Question: Someone knows a trick how to access generated Razor source code with Asp.Net Core?

I'm building a webapp in ASP.NET and am trying to get a button (a Panel) to load a "window" or sub application to add new users. I want the div holding the buttons to transitionally clear or be "deleted" and in the same window, load the corresponding application/div. Most people suggest Ajax but none of the answers I've found have the desired effect I want. Below is a sample of the button/panel item which is contained in a div that is 100% vh and 100% vw. I'm not exactly familiar with jQuery either which doesn't help.

Thanks in advance.

<div class="admin-panel">
            <div class="row admin-controls">
                <div class="col-md-2"></div>
                <div class="col-md-2">
                    <asp:Panel runat="server" >
                        <div class="admin-control-item" onclick=""><!-- This is the button to load the application -->
                             <i class="material-icons md-48">people</i>
                             <h3>Current Users</h3>
                         </div>
                    </asp:Panel>
                </div>
...
</div>

I have a MVC Web API (hosted in IIS) which is in the wwwroot folder and locally accessible within the network.I can execute api calls like this: http://mylocalapi:133/api/Values/Get and I get a result.

I have an external site which is http://example.org and I would like to execute the same http://mylocalapi:133/api/Values/Get.

I have CORS set up in my API like this:

[EnableCors(origins: "http://example.org", headers: "*", methods: "*")]

But I keep getting the following error:

XMLHttpRequest cannot load http://mylocalapi:133. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.org' is therefore not allowed access.

So get around it, I created a virtual directory (APICALLS) in my external site and created a web.config file which will point to the local IIS site:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="http://mylocalapi:133" exactDestination="true" />
    </system.webServer>
</configuration>

When I do that, I try to access the API like this: http://example.org/APICALLS/api/Values/Get but I get the following error:

XMLHttpRequest cannot load http://mylocalapi:133. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.org' is therefore not allowed access.

What am I doing wrong and how can I resolve the issue.

I've a Many to Many relation between a student (etudiant) and a course (cours) table which is called studentCours in SQL but not use as a model in Entity Framework (i've taken the habit of it now, even if i think its weird).

I need to show the result of the student (which is on another table etuResult) but the student may not have any result (nullable int) yet as the year is still in progress !

I'm able to get the value of studentCours and show them and also of studentResult, but i'm not able to show the concatenation of both (and leave the result empty or with other value than a number between 1 and 20).

On the following picture you can see :

On the left : the student with the id 3 has 2 cours with the id 1 and 10 (i dont know why the course_id 1 appears twice...) => These are the course he's following.

On the right : The student with the id 3 has one result for the course_id 10 and has the result 10/20

getResult (left) and getCourse (right)

Here are my two queries to get the data :

var etuCours = from c in bdd.cours
         where c.etudiant.Any(e => e.etudiant_id == id)
         select new resultCours { cours_id = c.cours_id, libelle = c.libelle, code = c.code, annee = c.annee };
IEnumerable<resultCours> etuResult = from er in bdd.etuResult
         where er.etudiant_id == id
         select new resultCours { cours_id = er.cours_id, cote = er.cote };

I want to execute a RegisterStartupScript calling a Javascript function after certain processes happen in my code behind. It is basically a Loading loop decoration made in CSS3. I show it (with javascript) on buttons clientclick, when I know the process will take a while and I hide it when the process is finished. Everything works fine, but now I have a process in Which I download a file using another empty webform using response.redirect. The file is downloaded fine, but the RegisterStartupScript call does not work. I understand the response is the problem, but nor I need to work in a workaround to solve this (I do not want to change the whole way, cause it is implemented in many other pages and processes. I wil provide the related code (not all), in case you can give me a direct way to solve it.

Javascript

function LoadingLoopOn()
{
    $('#outerAlignId').addClass("outerAlign");
    $('#middleAlignId').addClass("middleAlign");
    $('#innerAlignId').addClass("innerAlign");
    $('#OutterCircleId').addClass("OutterCircle");
    $('#InnerCircleId').addClass("InnerCircle");
    $('#Loadinglbl').addClass("LoadingLabelStyle");
}

function LoadingLoopOff()
{
    $('#outerAlignId').removeClass("outerAlign");
    $('#middleAlignId').removeClass("middleAlign");
    $('#innerAlignId').removeClass("innerAlign");
    $('#OutterCircleId').removeClass("OutterCircle");
    $('#InnerCircleId').removeClass("InnerCircle");
    $('#Loadinglbl').removeClass("LoadingLabelStyle");
}

HTML (it is on the master page, to be able to used it in every webform)

<asp:Panel ID="outerAlignId" ClientIDMode="Static" runat="server" CssClass="outerAlign">
    <div id="middleAlignId" class="middleAlign">
        <div id="innerAlignId" class="innerAlign">
            <div id="OutterCircleId" class="OutterCircle"></div>
            <div id="InnerCircleId" class="InnerCircle"></div>
            <asp:Label ID="Loadinglbl" ClientIDMode="Static" runat="server" Text="Loading..." CssClass="LoadingLabelStyle"></asp:Label>
        </div>
    </div>
</asp:Panel>

HTML Button Sample Where I want to used it

<asp:ImageButton ID="ExportExId" ClientIDMode="Static" runat="server" OnClientClick="LoadingLoopOn();"  OnClick="ExportExId_Click" CssClass="..." ImageUrl="..." />

And the CS# Code behind

    protected void ExportExId_Click(object sender, ImageClickEventArgs e)
    {
        //...
        //Many code and DB treatment goes here, to finally get a temporally Excel file in the server
        //..

        //I call the page with the file name and path
        Response.Redirect(String.Format("DownloadForm.aspx?FileName={0}&Path={1}", fileExported.Name, "Temp" + UserName));

        //This piece of code must be excuted in its webform after the redirect (once ee finished)
        ScriptManager.RegisterStartupScript(this, GetType(), "LoadingLoopOff", "LoadingLoopOff();", true);

    }

Many thanks,

I can't figure out what I'm doing wrong here. Trying to dynamically fill a dropdownlist inside a gridview and it keeps telling me the object reference is not set to an instance of an object.

First, my ASPX:

<asp:Panel runat="server" ID="ShowDiv3" Visible="false" BorderStyle="Solid" BorderWidth="0"  Width="1389px">
        <asp:Label ID="lblShowDiv3Title" runat="server" Text="Root Causes:    " Font-Bold="true"></asp:Label><asp:DropDownList ID="ddlRootCauses" runat="server" Width="300px" OnSelectedIndexChanged="ddlRootCauses_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
        <br />
        <%-- This line needed to be commented out when paging was removed: AllowPaging="True"  AllowCustomPaging="True" PageSize="10" --%>
        <div id="divGrid3" style='width:1290px; overflow:auto'>
    <asp:GridView ID="DataGrid_RootCauses" runat="server" 
        AllowSorting="True" OnSorting="DataGrid_RootCauses_Sorting" AutoGenerateColumns="False" ShowFooter ="true" CellPadding="1" 
        CssClass="hoverTable"
        HeaderStyle-BackColor="#4DA6A6" HeaderStyle-BorderColor="#4DA6A6" 
        HeaderStyle-Font-Size="Small" HeaderStyle-ForeColor="White"
        FooterStyle-BackColor="#4DA6A6" FooterStyle-BorderColor="#4DA6A6" FooterStyle-ForeColor="White"
        DataKeyNames="root_cause_id"
                        OnRowDataBound="DataGrid_RootCauses_RowDataBound"
        OnRowCancelingEdit="DataGrid_RootCauses_CancelCommand"   
        OnRowEditing="DataGrid_RootCauses_EditCommand" 
        OnRowDeleting="DataGrid_RootCauses_DeleteCommand"
        OnRowUpdating="DataGrid_RootCauses_UpdateCommand">  
            <Columns>  

            <asp:TemplateField HeaderText="LPI Due">  
            <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_LPI_DUE" runat="server" Width="70px" Text='<%#Eval("LPI_DUE") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_LPI_DUE" runat="server" Width="70px" Text='<%#Eval("LPI_DUE") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_LPI_DUE" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField>                    

        <asp:TemplateField HeaderText="Root Cause Category">  
            <ItemTemplate>  
                <asp:Label ID="lbl_LPI_Category" runat="server" Width="170px" Text='<%#Eval("LPI_Category") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_LPI_Category" runat="server" Width="170px" Text='<%#Eval("LPI_Category") %>'></asp:DropDownList>
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_LPI_Category" runat="server" Width="170px" ></asp:DropDownList>
            </FooterTemplate>
        </asp:TemplateField>                   

        <asp:TemplateField HeaderText="Root Cause Reason">  
            <ItemTemplate>  
                <asp:Label ID="lbl_LPI_Reason" runat="server" Width="370px" Text='<%#Eval("LPI_reason") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:TextBox ID="txt_RC_LPI_Reason" runat="server" Width="370px" Text='<%#Eval("LPI_reason") %>'></asp:TextBox>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:TextBox ID="ntxt_RC_LPI_Reason" runat="server" Width="370px" ></asp:TextBox>  
            </FooterTemplate>
        </asp:TemplateField>                 

        <asp:TemplateField HeaderText="Business Owned">  
            <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_Business" runat="server" Width="70px" Text='<%#Eval("Business") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_Business" runat="server" Width="70px" Text='<%#Eval("Business") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_Business" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField>   

        <asp:TemplateField HeaderText="CP Owned">  
        <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_CP" runat="server" Width="70px" Text='<%#Eval("CP") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_CP" runat="server" Width="70px" Text='<%#Eval("CP") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_CP" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField>                    

        <asp:TemplateField HeaderText="Non-CP Owned">  
        <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_Non_CP" runat="server" Width="70px" Text='<%#Eval("Non_CP") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_Non_CP" runat="server" Width="70px" Text='<%#Eval("Non_CP") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_Non_CP" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Proclaim">  
        <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_Proclaim" runat="server" Width="70px" Text='<%#Eval("Proclaim") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_Proclaim" runat="server" Width="70px" Text='<%#Eval("Proclaim") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_Proclaim" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="PMHS">  
        <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_PMHS" runat="server" Width="70px" Text='<%#Eval("PMHS") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_PMHS" runat="server" Width="70px" Text='<%#Eval("PMHS") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_PMHS" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Facets">  
        <ItemStyle HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>  
                <asp:Label ID="lbl_Facets" runat="server" Width="70px" Text='<%#Eval("Facets") %>'></asp:Label>  
            </ItemTemplate>  
            <EditItemTemplate>  
                <asp:DropDownList ID="ddl_RC_Facets" runat="server" Width="70px" Text='<%#Eval("Facets") %>'>
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </EditItemTemplate>  
            <FooterTemplate>  
                <asp:DropDownList ID="nddl_RC_Facets" runat="server" Width="70px" >
                    <asp:ListItem Value=""> - </asp:ListItem>
                    <asp:ListItem Value="N"> N </asp:ListItem>
                    <asp:ListItem Value="Y"> Y </asp:ListItem>
                </asp:DropDownList>  
            </FooterTemplate>
        </asp:TemplateField> 

        <asp:TemplateField ItemStyle-Width="90px">  
        <ItemTemplate>  
            <asp:Button ID="btn_Edit" runat="server" Text="Edit" CommandName="Edit" />  
        </ItemTemplate>  
        <EditItemTemplate>  
            <asp:Button ID="btn_Update" runat="server" Text="Update" CommandName="Update"/>  
            <asp:Button ID="btn_Cancel" runat="server" Text="Cancel" CommandName="Cancel"/>  
        </EditItemTemplate>  
        <FooterTemplate>
            <asp:Button ID="btn_Add" runat="server" Text="Add" OnClick="DataGrid_RootCauses_RowCreated" />
        </FooterTemplate>
        </asp:TemplateField>  
        <asp:TemplateField>  
        <ItemTemplate>  
            <asp:Button ID="btn_Delete" runat="server" OnClientClick="javascript:return confirm('Are you sure?');" Text="Delete" CommandName="Delete" />  
        </ItemTemplate>  
        </asp:TemplateField>        
        <asp:TemplateField HeaderText="Cause ID">  
        <ItemTemplate>  
            <asp:Label ID="lbl_Cause_ID" runat="server" Text='<%#Eval("root_cause_id") %>'></asp:Label>  
        </ItemTemplate>  
        </asp:TemplateField>        

        </Columns>  
    </asp:GridView>  
    <asp:Label ID="lblEmpty1" runat="server" Visible="false" Style="font-weight:bold; font-size:large;"></asp:Label>
    </div> 
</asp:Panel>

Now, the code-behind:

protected void  ddlRootCauses_SelectedIndexChanged(object sender, EventArgs e)
{
    LoadRootCauseGrid();

    OracleConnection conn = GetConnection();
    try
    {
        {
            // ddlRootCauses
            OracleCommand cmd6 = new OracleCommand();
            cmd6.CommandType = CommandType.StoredProcedure;
            cmd6.CommandText = "SP_LPI_MAINT_LIST_ROOTCAUSE";
            cmd6.Connection = conn;

            //cmd3.Parameters.Add("v_Lookup_Value", OracleType.VarChar, 20).Value = "LEAD";
            cmd6.Parameters.Add("vRootCauseList", OracleType.Cursor).Direction = ParameterDirection.Output;

            var SearchAdapter6 = new OracleDataAdapter(cmd6);
            var ds6 = new DataTable();
            SearchAdapter6.Fill(ds6);

            DataView view = new DataView(ds6);
            DataTable distinctValues = new DataTable();
            distinctValues = view.ToTable(true, "LPI_Category");

            // Fill all of the dropdowns from the same data adapter
            {
                //This one works fine
                ddlRootCauses.DataSource = distinctValues;
                ddlRootCauses.DataTextField = "LPI_Category";
                ddlRootCauses.DataValueField = "LPI_Category";
                ddlRootCauses.DataBind();
                ddlRootCauses.Items.Insert(0, new ListItem("All", ""));

                //This one send me down to the Catch block on the first line
                ddl_RC_LPI_Category.DataSource = distinctValues;
                ddl_RC_LPI_Category.DataTextField = "LPI_Category";
                ddl_RC_LPI_Category.DataValueField = "LPI_Category";
                ddl_RC_LPI_Category.DataBind();
                ddl_RC_LPI_Category.Items.Insert(0, new ListItem("All", ""));

                nddl_RC_LPI_Category.DataSource = distinctValues;
                nddl_RC_LPI_Category.DataTextField = "LPI_Category";
                nddl_RC_LPI_Category.DataValueField = "LPI_Category";
                nddl_RC_LPI_Category.DataBind();
                nddl_RC_LPI_Category.Items.Insert(0, new ListItem("All", ""));

            }

            ds6.Dispose();
            cmd6.Dispose();
            SearchAdapter6.Dispose();

            conn.Close();
        }
    }
    catch (Exception ex)
    {
            Response.Write(ex.Message);
            conn.Close();
    }

}

Oddly enough, ddlRootCauses gets populated with no problems. But, that dropdownlist is outside of the gridview. I don't understand why it's having trouble with the dropdownlist inside the gridview. And, it can't just be because gridviews don't like dropdowns; the Y/N ones with hardcoded listitems work fine.

I am having mvc 4.5 project project and I am trying to use angular cli but it seems like I am missing steps to make it work, I have tried to use angular 2 seed project and it works fine. please help me with angular cli configuration on MVC 4.5.

thank you.

I write id to TempData in one action method like this

[HttpPost]
    public ActionResult Index(string question1, string question2, string question3, string question4, string question5, string question6, string question7, string question8, string question9, string question10, Int32 id)
    {
        QuestionBlock question = new QuestionBlock
        {
            Question1 = question1,
            Question2 = question2,
            Question3 = question3,
            Question4 = question4,
            Question5 = question5,
            Question6 = question6,
            Question7 = question7,
            Question8 = question8,
            Question9 = question9,
            Question10 = question10,
            Interview_Id = id,
        };

       // ViewBag.ID = id;
        TempData["id"] = id;
        db.QuestionBlocks.Add(question);
        db.SaveChanges();

        return Json(new { Result = "Success", Message = "Saved Successfully" }, JsonRequestBehavior.AllowGet);

    }

And try to update value in database like this in other

public ActionResult Update(string start, string end, string link)
    {

        ApplicationDbContext context = new ApplicationDbContext();
        var id = (int?)TempData["id"];
        IEnumerable<InvitationMail> customers = context.InvitationMails
            .Where(c => c.LinkStart == null)
            .Where(c => c.LinkEnd == null)
            .Where(c => c.Link == null)
            .Where(c=>c.Interview_Id==null)
            .AsEnumerable()
            .Select(c => {
                c.LinkStart = start;
                c.LinkEnd = end;
                c.Link = link;
                c.Interview_Id = id;
               return c;
            });


        foreach (InvitationMail customer in customers)
        {
            customer.Interview_Id = id;
            // Указать, что запись изменилась
            context.Entry(customer).State = EntityState.Modified;
        }

I set breakpoints and see that data in id. But it not writing to database.

Where is my fault?

thank's for help.

Here is my code:

public void SaveAs(string path) // path = "C:\\Users\\MyName\\Documents\\myImage.png"
{
    using (var file = System.IO.File.Open(path, FileMode.CreateNew))
    {
        // FileStream was created like this:
        // Stream FileStream = new MemoryStream(23201);
        FileStream.CopyTo(file); 
        file.Close();
    }
}

After calling the function, the file will be created but its size will be 0. This is the problem.

I searched for two days but couldn't get the solution. Any help will be appreciated. Thank you very much in advance.

Does chart.js able to display the difference between two values that are positioned on the same spot?

Currently in my chart, if there are more than one value that is on the same axis, the newer value will get "pinched" by the older one therefore I cannot see it.

Any workaround?

I have the below code to format the date on my views.

[DisplayName("Date Last Seen")]
[DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime? LostDate { get; set; }

It all works except that when I click the Edit view the current value of "LostDate" does not get rendered automatically.

How do I fix this?

Edit I have the code below for the edit view.

<div class="form-group">
    @Html.LabelFor(model => model.LostDate, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.LostDate, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.LostDate, "", new { @class = "text-danger" })
    </div>
</div>

I'm new on creating Web Api's and I need to pass a string to GetAsync method but I don't know what should I add to WebApiConfig file and how on GetAsync after the change. I've searched here but I've found nothing that helped me. Can anyone help me please?

My procedure:

private async void registrarServico(string nomeServico)
{
    using (HttpClient clientGet = new HttpClient())
    using (HttpClient clientSet = new HttpClient())
    {
        clientGet.BaseAddress = new Uri("api/ControladorServico/GetServico");
        var respostaGet = await clientGet.GetAsync("", nomeServico); //ERROR HERE!
    }
}

My WebApiConfig:

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{action}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

My API method:

[HttpGet]
public IHttpActionResult GetServico(string nomeServico)
{
    try
    {
        return Ok(controladorServicoRep.CONTROLADOR_SERVICOSep.Get(d => d.NOME == nomeServico && d.MAQUINA == nomeMaquina).FirstOrDefault());
    }
    catch (Exception)
    {
        throw;
    }
}

Thank you.