小编New*_*Bie的帖子

如何从AppSettings.Config文件中获取键值?

我正在尝试在appsettings.Config文件中设置我的键值,但似乎无法正常工作.

这就是我为此写的.代码从MDI文件的构造函数调用,并且仅返回null值.谁知道为什么?

     var getValue = ConfigurationSettings.AppSettings["ShowQueryTextbox"];
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用ConfigurationManager.AppSettings.那也没有用.

我的AppSettings代码如下.

<configuration>
  <appSettings>
    <add key="ShowQueryTextbox" value="true"/>
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

c# appsettings

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

单击即可打开下拉列表(在数据网格视图中)

我怎样才能避免双击一个DropDownButton用过的DataGridView?现在,我可以DataGridView通过单击两次或更多次来查看其中的下拉项.第一次选择单元格,第二次单击DropDownButton箭头时,它显示列表.如何通过一次点击实现同样的目标?

c# datagridview winforms datagridviewcomboboxcell

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

如何将复选框控件添加到数据表?

如何在数据表中添加复选框并将其绑定到数据网格?

DataTable ColumnList = new DataTable();
ColumnList.Columns.Add("Column Fields");

int j = 1, i = 0;
CheckBox colCheckbox = new CheckBox();
foreach (Columns col in ColumnNames)
{
    colCheckbox.Name = col.ColumnName;       
    ColumnList.Rows.Add(colCheckbox); // This is getting displayed as System.Windows.Forms.CheckBox,CheckState=0
}
Run Code Online (Sandbox Code Playgroud)

请帮忙.

.net c# datatable

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

最大请求长度超过回发时的异常

我在点击按钮时遇到以下异常,对于在页面加载时在gridview中绑定超过500条记录的asp页面.

我的页面没有任何上传控件.它包含一个文本框,按钮和gridview.有谁知道为什么会这样.

例外说明:

Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Run Code Online (Sandbox Code Playgroud)

.net asp.net

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

如何计算上传文件的百分比?

我需要计算上传到服务器的文件的百分比.我读的就像

上传的百分比= 100 /文件大小*上传的字节数.

有谁知道我们如何从文件上传控件的属性中获取以下内容:

  1. 上传文件的大小
  2. 字节已上传

请帮忙.谢谢

c# asp.net file-upload

5
推荐指数
1
解决办法
3647
查看次数

在线.Net编码

这可能不是这个问题的平台,但我仍然很想知道我是否可以在线练习视觉工作室编码.有谁知道这样的网站?

我的实践意味着在线编写和运行.net程序.谢谢

.net asp.net

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

如何在字符串的字符之间插入空格

有没有一种简单的方法在字符串的字符之间插入空格?我正在使用下面带有字符串的代码(例如(UI $ .EmployeeHours*UI.DailySalary)/(Month)).由于此信息来自Excel工作表,我需要为每个列名插入[].如果用户避免在每个paranthesis之后给出空格以及操作符,则会出现问题.AnyOne有帮助吗?

      text = e.Expression.Split(Splitter);
      string expressionString = null;
      for (int temp = 0; temp < text.Length; temp++)
                        {
                            string str = null;
                            str = text[temp];
                            if (str.Length != 1 && str != "")
                            {
                                expressionString = expressionString + "[" + text[temp].TrimEnd() + "]";
                            }
                            else
                                expressionString = expressionString + str;

                        }
Run Code Online (Sandbox Code Playgroud)

用户可能正在输入类似(UI $ .SlNo-UI + UI $ .Task) - (UI $ .Responsible_Person*UI $ .StartDate),而我想要的输出是([UI $ .SlNo-UI] + [UI $.任务]) - ([UI $ .Responsible_Person]*[UI $ .StartDate])

c#

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

如何使用sql参数进行选择查询?

我需要根据与一组记录的'like'匹配来获取记录,

以下查询即时使用无效.有谁知道查询有什么问题?

 sqlCommand.CommandText =String.Format("SELECT * FROM Customer" +
                " WHERE (Name like @Name)","'%" +searchString.Trim()+"%'");
            sqlCommand.Parameters.AddWithValue("Name", searchString);
Run Code Online (Sandbox Code Playgroud)

此查询不提取所需的记录.

运行上面的代码片段时出现以下错误:

Must declare the scalar variable "@Name".
Run Code Online (Sandbox Code Playgroud)

c# sql-server

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

清除列表框中的选中项目而不触发itemcheck事件

我在form2(clbForm2)中有一个checkedlist框,我明确地将它映射到项目检查事件.现在我需要从form2中取消选中Form1中控件的所有选中项.在取消选中项目时,它会触发项目检查事件.有没有办法跳过这个事件.我在其中编写代码,我不想在从form2调用时运行.请建议一个好方法.

.net c# mdi checkedlistbox

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

如何使用linq语句查询?

我有两个对象

List<Report> 
List<Newsletter>
Run Code Online (Sandbox Code Playgroud)

我需要某些属性,如

Id
Date
Status
text
Run Code Online (Sandbox Code Playgroud)

从两个名单.有没有办法合并这些列表并使用linq语句查询它以将特定属性作为单独的列表返回?请帮忙.

对象的结构如下:

Report
{
    int id,
    datetime reportDate, 
    enum Status,
    string text
};

Newsletter
{
    int id, 
    datetime newsletterDate,
    string Status,
    string text
};
Run Code Online (Sandbox Code Playgroud)

c# linq

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

日期时间转换异常

我正在尝试格式化日期时间列表。一个日期的格式与我提供的格式相同,但因素没有到位。下面给出了这行代码。有人能告诉我如何跳过下面一行的错误吗?

Convert.ToDateTime("22-01-2013 00:00:00").ToString("yyyy-MM-dd");
Run Code Online (Sandbox Code Playgroud)

c# asp.net datetime

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

通配符是否可以处理对象?

是否可以在参数中使用通配符?我有这个代码重复的属性TextLine1,TextLine2,TextLine3和TextLine 4.是否可以用通配符替换数字,以便我可以根据用户输入传递数字.

TextLine1,TextLine2,TextLine3和TextLine 4是ReportHeader类的属性.

 public Control returnTextLine(ReportHeader TextLineObj,int i)
    {

        System.Windows.Forms.Label lblTextLine = new System.Windows.Forms.Label();
        lblTextLine.Name = TextLineObj.**TextLine1**.Name;
        lblTextLine.Font = TextLineObj.**TextLine1**.Font;
        lblTextLine.ForeColor = TextLineObj.**TextLine1**.ForeColor;
        lblTextLine.BackColor = TextLineObj.**TextLine1**.BackgroundColor;
        lblTextLine.Text = TextLineObj.**TextLine1**.Text;
        int x = TextLineObj.**TextLine1**.x;
        int y = TextLineObj.**TextLine1**.y;
        lblTextLine.Location = new Point(x, y);


        return lblTextLine;
    }
Run Code Online (Sandbox Code Playgroud)

请帮忙...

c#

0
推荐指数
1
解决办法
102
查看次数

如何使用多个参数调用Post api

如何使用HttpClient调用具有多个参数的Post方法?

我使用以下代码与一个参数:

var paymentServicePostClient = new HttpClient();
paymentServicePostClient.BaseAddress = 
                  new Uri(ConfigurationManager.AppSettings["PaymentServiceUri"]);

PaymentReceipt payData = SetPostParameter(card);
var paymentServiceResponse = 
   paymentServicePostClient.PostAsJsonAsync("api/billpayment/", payData).Result;
Run Code Online (Sandbox Code Playgroud)

我需要添加另一个参数userid.如何将参数与'postData'一起发送?

WebApi POST方法原型:

public int Post(PaymentReceipt paymentReceipt,string userid)
Run Code Online (Sandbox Code Playgroud)

c# httpclient asp.net-web-api

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