小编the*_*van的帖子

在C#.Net中将十进制转换为字符串的问题

在将Decimal转换为String时,我尝试了两种方法.

方法1:

    string a = "100.00", b = "50.00";
    string Total = (string)(Convert.ToDecimal(a) + Convert.ToDecimal(b));
Run Code Online (Sandbox Code Playgroud)

它抛出错误,无法将Decimal转换为String.

方法2:

    string Total = (Convert.ToDecimal(a) + Convert.ToDecimal(b)).ToString();
Run Code Online (Sandbox Code Playgroud)

它没有抛出错误,它工作正常.

我想知道这两种转换方法之间的区别以及当我使用方法1时它为什么会抛出错误?

c# asp.net user-controls types decimal

4
推荐指数
1
解决办法
1万
查看次数

在SQL Server中使用Sum Aggregate函数进行内部联接

我有三个表StockSummary,Item,ItemSpecification.在这里,我想加入这三个表并获得Sum(StockSummary.Quantity).主要栏目如下:

TableA: StockSummary(ItemID, Quantity)
TableB: Item(ItemID, ItemName, SpecificationID)
TableC: ItemSpecification(SpecificationName, SpecificationID)
Run Code Online (Sandbox Code Playgroud)

期望的结果应该给出ItemName,SpecificationName和SUM(Quantity).如何在Inner Joins中使用Aggregate函数?

sql sql-server-2005 sum inner-join aggregate-functions

4
推荐指数
1
解决办法
2万
查看次数

更新选择使用NULL值连接

我有两个表STR_IndentDetail和PUR_POIndent

STR_IndentDetail:

   IndentID   ItemID    POQty     D1      D2       D3        RD
  ---------   -------  ------    ----     ---     ---        ---
    2            1       NULL     10       20      30        NULL
    2            6       NULL     20       40      60        45
Run Code Online (Sandbox Code Playgroud)

PUR_POIndent:

   POID        IndentID      ItemID     Quantity     D1     D2       D3        RD
  ------      ----------     ------    ----------   ----    ---      ---       ---
    2            2             1           55         10     20      30        NULL
    2            2             6           100        20     40      60         45
Run Code Online (Sandbox Code Playgroud)

我想用PUR_POIndent表数量更新STR_IndentDetail表POQty.我已经根据INNER JOIN和LEFT OUTER编写了两个Update语句.但两个查询仅更新一行,其中列D1,D2,D3和RD中的值.包含具有NULL值的列RD的行未获得UPDATE.如何为此案例编写更新声明.以下是我的两个更新声明.

基于内部联接:

     UPDATE STR_IndentDetail
                SET
                    POQty = PUR_POIndent.Quantity
                FROM
                    PUR_POIndent
                WHERE
                    PUR_POIndent.IndentID           = STR_IndentDetail.IndentID AND …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2005 sql-server-2008 sql-update

4
推荐指数
1
解决办法
3006
查看次数

基于条件跳转到不同的开关案例,如goto

我需要根据条件从一个案例转移到另一个案例.例如,这是我的代码:

switch (req.method) {
  case 'GET':
    alert('GET METHOD');
    break;
  case 'POST':
    alert('POST METHOD');
    break;
  case 'PUT':
    alert('PUT METHOD');
    break;
  default:
    res.end();
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,在POST我需要检查的情况下,例如if(A === B),然后转到这样的PUT情况.这该怎么做?

javascript switch-statement

4
推荐指数
2
解决办法
5103
查看次数

通过电子邮件发送图表

我想使用ASP.Net和C#在电子邮件的正文中发送折线图。我已经编写了代码以在div标签中显示图表。我想通过邮件发送折线图。这该怎么做?

My Code: jQuery

    var chartData;
    google.load("visualization", "1", { packages: ["corechart"] });

    function Chart() {
        $.ajax({
            url: "HHT_Tracking.aspx/GetData",
            data: "",
            dataType: "json",
            type: "POST",
            contentType: "application/json; chartset=utf-8",
            success: function (data) {
                chartData = data.d;
            },
            error: function () {
                alert("Error loading data! Please try again.");
            }
        }).done(function () {
            //google.setOnLoadCallback(drawChart);
            drawChart();
        });
    };

    function drawChart() {
        var data = google.visualization.arrayToDataTable(chartData);

        var options = {
            title: "Server Monitoring Date Wise",
            pointSize: 5,
            vAxis: { slantedText: true, slantedTextAngle: 90, title: 'MINUTES' } …
Run Code Online (Sandbox Code Playgroud)

c# asp.net email linechart

4
推荐指数
2
解决办法
5507
查看次数

如何使用 C# 从 GridView_RowDeleting 事件中的 GridView 获取 ID?

我想删除 Gridview 中的某一行。所以我需要ID,如何在GridView_RowDeleting事件中获取行的ID?

这是 GridView 的列列表,

<Columns>
  <asp:TemplateField HeaderText="S.No." ControlStyle-Width="100%" ItemStyle-Width="30px">
    <ItemTemplate>
      <asp:Label ID="lblSrno" runat="server" Text=''
        <%# Container.DataItemIndex + 1 %>'></asp:Label>
    </ItemTemplate>
    <ControlStyle Width="100%" />
    <ItemStyle Width="30px" />
  </asp:TemplateField>
  <asp:TemplateField Visible="false">
    <ItemTemplate>
      <asp:Label runat="server" ID="lblDrawingID" Text=''
        <%# Bind("DrawingID")%>'></asp:Label>
    </ItemTemplate>
  </asp:TemplateField>
  <asp:BoundField DataField="CustDrawingNbr" HeaderText="Customer Drawing No." />
  <asp:TemplateField HeaderText="Status" ControlStyle-Width="100px" ItemStyle-Width="100px">
    <ItemTemplate>
      <asp:DropDownList ID="ddlStatus" runat="server" Width="100px" Enabled="false">
      </asp:DropDownList>
    </ItemTemplate>
    <ControlStyle Width="100px" />
    <ItemStyle Width="100px" />
  </asp:TemplateField>

  <asp:TemplateField Visible="false">
    <ItemTemplate>
      <asp:Label runat="server" ID="lblDrawingPGMAStatusID" Text=''
        <%# Bind("StatusID")%>'></asp:Label>
    </ItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField Visible="false">
    <ItemTemplate>
      <asp:Label …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

3
推荐指数
1
解决办法
3万
查看次数

如何在Asp.Net中设置上传文件的物理路径?

我想在物理路径中上传文件,例如E:\Project\Folders.

我在网上搜索下面的代码.

//check to make sure a file is selected
if (FileUpload1.HasFile)
{
    //create the path to save the file to
    string fileName = Path.Combine(Server.MapPath("~/Files"), FileUpload1.FileName);
    //save the file to our local path
    FileUpload1.SaveAs(fileName);
}
Run Code Online (Sandbox Code Playgroud)

但在这方面,我想像上面提到的那样给出我的物理路径.这该怎么做?

c# asp.net file-upload visual-studio-2010

3
推荐指数
1
解决办法
4万
查看次数

WCF:relativeAddress,baseAddress和binding

我是WCF的新手,并开始使用一个简单的无文件应用程序,其中一部分(web.config)可以在下面看到:

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
        <serviceActivations>
            <add
                factory="System.ServiceModel.Activation.ServiceHostFactory"
                relativeAddress="./RelativeAddress.svc"
                service="WCF_Transactions.MyService1"/>
        </serviceActivations>
    </serviceHostingEnvironment>
Run Code Online (Sandbox Code Playgroud)

现在我可以访问服务了

http://localhost:18148/RelativeAddress.svc
Run Code Online (Sandbox Code Playgroud)

然后我添加下一行:

    <services>
        <service name="WCF_Transactions.MyService1" behaviorConfiguration="MyBehavior1">
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:18148/" />
                </baseAddresses>
            </host>
            <endpoint  address="/RelativeAddressX.svc" binding="basicHttpBinding" contract="WCF_Transactions.IService1"></endpoint>
        </service>
    </services>

    <behaviors>
        <serviceBehaviors>
            <behavior name="MyBehavior1">
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
Run Code Online (Sandbox Code Playgroud)

所以我希望我的服务可以通过下一个地址访问:

  http://localhost:18148/RelativeAddressX.svc
Run Code Online (Sandbox Code Playgroud)

但我不能这样做.我误解了什么?

wcf web-config wcf-binding

3
推荐指数
1
解决办法
2万
查看次数

什么是ASP.Net中的CSS,主题和皮肤?

我是ASP.Net的初学者.我想知道ASP.Net中的CSS,主题和皮肤是什么?以及如何在ASP.Net中创建和使用这些东西?请用简单的例子来解释.谢谢.

css c# asp.net themes skin

2
推荐指数
1
解决办法
4238
查看次数

ASP.NET MVC将来会取代ASP.NET Web Forms吗?

我在ASP.NET Web应用程序中工作.我不知道MVC和ASP.NET MVC.我读到ASP.NET和ASP.NET MVC是不同的.我是ASP.NET的初学者.现在每个人都问过我关于ASP.NET MVC的问题.所以我对学习ASP.NET或学习ASP.NET MVC感到困惑.将来,无论是ASP.NET还是ASP.NET MVC,哪一个都会优先考虑?我需要你的所有建议.

asp.net asp.net-mvc visual-studio-2008

2
推荐指数
1
解决办法
5505
查看次数