小编Myw*_*rld的帖子

将CSS类添加到后面的代码中的div

我有一个div,我试图在代码中添加一个CSS类,但我尝试时收到以下错误

Property or indexer 'System.Web.UI.HtmlControls.HtmlControl.Style' cannot be assigned to -- it is read only
Run Code Online (Sandbox Code Playgroud)

我使用以下代码:

protected void BTNEvent_Click(object sender, ImageClickEventArgs e)
{
    BtnventCss.Style= "hom_but_a";                 
}
Run Code Online (Sandbox Code Playgroud)

谁能帮帮我吗?

css c#

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

如何解决"超出最大请求长度"异常?

当我上传图片时出现此错误:

超出最大请求长度

我该如何解决这个问题?

asp.net

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

旧格式或无效类型库.(来自HRESULT的异常:0x80028018(TYPE_E_INVDATAREAD))

将数据网格视图中的数据导出到Excel工作表时出现错误:

错误(旧格式或无效的类型库.(HRESULT异常:0x80028018(TYPE_E_INVDATAREAD)))

在这条线上:

Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

我的完整代码:

private void button1_Click(object sender, EventArgs e)
{
    System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

    // Creating Excel Application
    Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
    System.Threading.Thread.CurrentThread.CurrentCulture = oldCI;

    // Creating new WorkBook within Excel application
    Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);

    // Creating new Excel sheet in workbook
    Microsoft.Office.Interop.Excel._Worksheet worksheet = null;

    // See the Excel sheet behind the program
    //Funny
    app.Visible = true;

    // Get the reference of first sheet. By default its …
Run Code Online (Sandbox Code Playgroud)

c# excel datagridview winforms

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

在绑定数据库中的数据之前,将项添加到组合框

我有一个Windows窗体中的组合框,它从数据库中检索数据.我做得很好,但我想在数据库中添加第一项<-Please select Category->.我怎样才能做到这一点?我在哪里可以买到它?

public Category()
{
    InitializeComponent();
    CategoryParent();

}

private void CategoryParent()
{
    using (SqlConnection Con = GetConnection())
    {
        SqlDataAdapter da = new SqlDataAdapter("Select Category.Category, Category.Id from Category", Con);
        DataTable dt = new DataTable();
        da.Fill(dt);
        CBParent.DataSource = dt;
        CBParent.DisplayMember = "Category";
        CBParent.ValueMember = "Id";
    }
}
Run Code Online (Sandbox Code Playgroud)

c# combobox winforms

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

如何使用SQL Server 2008截断表?

我想截断表,但列值等于NULL

truncate table FB_Player where FB_Player.Status ='NULL'
Run Code Online (Sandbox Code Playgroud)

sql-server-2008

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

多语言网站

如何创建包含更多语言的网站?

asp.net

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

在网站上显示视频

我有解决方案在我的公司网站上显示视频,我的经理告诉我将网站上的所有视频添加为列表并将其列入(最近的视频,大多数视图)请求我希望任何人帮助我如何做到这一点?

请注意此链接 http://www.yallakora.com/arabic/YKChampions/EmbedListing.aspx?region=

c#

5
推荐指数
2
解决办法
253
查看次数

只读gridview中的列

我有Gridview绑定sqldatasource,我有登录看到gridview,我为这些登录创建了角色,他们无法看到所有gridview列,所以我怎么能让一些列只读.

code public void CheckLoginAuthorty(){

    using (SqlConnection Con = Connection.GetConnection())
    {
        SqlCommand com = new SqlCommand("CheackLoginInRole", Con);
        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.Add(Parameter.NewNVarChar("@Login", Session.Contents["Username"].ToString()));
        object O = com.ExecuteScalar();

        if (O != null)
        {
            string S = O.ToString();

            if (IsInRole("AR-Translator", O.ToString()))
            {
            ///////// Grideview code/////////////////   
            }

            else if (IsInRole("EN-Translator", O.ToString()))
            {
       /////////Grideview code/////////////////   
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

保存文件对话框并导出到Excel工作表

我有一个数据网格视图,我已导出到Excel工作表.代码运行良好,但当出现另存为对话框并保存文件时,我找不到文件,也没有出现错误.

我的代码

private void button1_Click(object sender, EventArgs e)
{
    try
    {
        using (new ExcelUILanguageHelper())
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Execl files (*.xls)|*.xls";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.CreatePrompt = true;
            saveFileDialog.Title = "Export Excel File To";

            Excel.ApplicationClass ExcelApp = new Excel.ApplicationClass();
            ExcelApp.Application.Workbooks.Add(Type.Missing);
            ExcelApp.Columns.ColumnWidth = 30;
            for (int i = 0; i < DGData.Rows.Count; i++)
            {
                DataGridViewRow row = DGData.Rows[i];
                for (int j = 0; j < row.Cells.Count; j++)
                {
                    ExcelApp.Cells[i + 1, j + …
Run Code Online (Sandbox Code Playgroud)

c# datagridview export-to-excel savefiledialog

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

在网格视图中查找控件

我有代码在gridview中找到标签,我检查了它,s标签文本,它给了我索引而不是文本和这个错误apear对象参考不设置为.....所以我想给CU.Username = LBL.文本; 文本没有控制代码索引

protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{                
    LblRseult.Visible = true;
    LblRseult.Text = "Successfully Process";
}

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    cUser CU = new cUser(this);

    LBL = (Label)GridView1.Rows[e.RowIndex].Cells[1].FindControl("Label1");
    CU.Username = LBL.Text;
    if (CU.BasiclyExists())
    {
        LblRseult.Visible = true;
        LblRseult.Text = "This user already exists";
    }     
}
Run Code Online (Sandbox Code Playgroud)

c#

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

在ASP.Net中,如何在新窗口中打开链接?

我有一个按钮,可以将用户重定向到另一个页面.相反,我希望这个按钮打开一个指向这个位置的新窗口.有人可以帮我这样做吗?

ASPX:

<asp:ImageButton ID="img_url"
                 CommandName='<%#Eval("url") %>'
                 OnClick="img_url_Click"
                 runat="server"
                 ImageUrl="~/images/products_details.png"
                 />
Run Code Online (Sandbox Code Playgroud)

CS:

protected void img_url_Click(object sender, ImageClickEventArgs e)
{
    ImageButton img = sender as ImageButton;
    Response.Redirect(img.CommandName.ToString());
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

错误语法不正确

我有注册表单,我在这个表单的用户名文本框中,当我测试网页表单时,我在文本框用户名(Kaz'em)中添加了这个用户,我有这个错误

('em'附近的语法不正确.字符串''后面的未闭合引号.)

public bool RegisteredUser()
{
    bool Return = false;
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ElarabyGroup"].ConnectionString);
    SqlCommand cmd = new SqlCommand("Select Count(UserName) From [Registeration] Where [Registeration].UserName = '" + RegisteredUserName + "'", con);
    con.Open();
    if (int.Parse(cmd.ExecuteScalar().ToString()) > 0)
        Return = true;
    con.Close();
    return Return;
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

无法将string []转换为字符串

我有错误"无法将字符串[]转换为字符串"

string[] digitsArray = {dd, pp, ff, cc};
Run Code Online (Sandbox Code Playgroud)

由于digitsArray数组的数组和所有"dd,pp,ff,cc"数组都有字符串值

c# arrays

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