小编Tar*_*sov的帖子

我如何过滤数据表?

我使用DataTable和有关用户的信息,我希望在此DataTable中搜索用户或用户列表.我试试但是不起作用:(

这是我的c#代码:

 public DataTable GetEntriesBySearch(string username,string location,DataTable table)
        {
            list = null;
            list = table;

            string expression;
            string sortOrder;

            expression = "Nachname = 'test'";
            sortOrder = "nachname DESC";

            DataRow[] rows =  list.Select(expression, sortOrder);

            list = null; // for testing
            list = new DataTable(); // for testing

            foreach (DataRow row in rows)
            {
                list.ImportRow(row);
            }

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

c# asp.net datatable filter dataset

68
推荐指数
6
解决办法
25万
查看次数

如何使用Linq将dataTable过滤到数据表?

您好我如何使用linq过滤数据表到数据表?我有一个DropDownList,我可以选择模块列的值.现在我想用这个模块列过滤DataTable.

这是我的数据表结构:

User | Host | TimeDiff | License | Telefon | Modul 
Run Code Online (Sandbox Code Playgroud)

这里的代码:

protected void drp_Modules_SelectedIndexChanged(object sender, EventArgs e)
{
    string value = drp_Modules.SelectedValue;

    DataTable tb = (DataTable)Session["dt_Users"];

    tb = from item in tb //?????

    LoadUsertable(tb);
}
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net datatable linq-to-dataset

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

如何使用searchstring搜索数据表中的行?

嗨,我想在我的DataTable中搜索行,我试试这个:

 protected void imggastsuche_Click(object sender, EventArgs e) 
        {
            string searchstring = txtgastsuche.Text;

            DataTable tb = DataBaseManager.GetDataTable(mysqlconnectionstring);

            DataRow[] foundRows = tb.Select("FIRSTNAME,LASTNAME,NAME,COMPANY,TIMEFROM,TIMETO,CREATOR Like '%" + searchstring + "%'");

            tb = foundRows.CopyToDataTable();

            this.ListView.DataSource = tb;
            this.ListView.DataBind();

        }
Run Code Online (Sandbox Code Playgroud)

但我的字符串中有错误.如果我想搜索此列,我该怎么办?

c# datatable listview datarow

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

我如何直接在C#中执行批处理命令?

嗨我对c#和批处理文件有疑问.我想执行批处理命令并将输出保存在c#中的字符串中.但我只能执行该文件,但不能将此内容保存在字符串中,并在文本框中显示.

我的批处理文件:

@echo关闭

"C:\ lmxendutil.exe"-licstatxml -host serv005 -port 6200> C:\ Temp\HW_Lic_XML.xml notepad C:\ Temp\HW_Lic_XML.xml

这是我的c#代码:

private void btnShowLicstate_Click(object sender, EventArgs e)
{
     string command = "'C:\\lmxendutil.exe' -licstatxml -host lwserv005 -port 6200";

     txtOutput.Text = ExecuteCommand(command);
}

static string ExecuteCommand(string command)
{
     int exitCode;
     ProcessStartInfo processInfo;
     Process process;

     processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
     processInfo.CreateNoWindow = true;
     processInfo.UseShellExecute = false;
     // *** Redirect the output ***
     processInfo.RedirectStandardError = true;
     processInfo.RedirectStandardOutput = true;

     process = Process.Start(processInfo);
     process.WaitForExit();

     // *** Read the …
Run Code Online (Sandbox Code Playgroud)

c# xml binary batch-file bin

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

如何在Active Directory中找到具有GUID(objectGUID)参数的用户

在我的ASP.NET应用程序中,我从Active Directory获取信息.我必须使用GUID信息获取有关用户的信息(例如:a28a6a34dsfdsf57d9e54f945a241),但我不知道如何使用右侧过滤器进行此搜索:/

例如,如果我搜索用户姓氏:

DirectoryEntry Entry = new DirectoryEntry("LDAP://" + "Domain");

            string filter = "(&(objectClass=user)(objectCategory=person)(cn=" + txtBenutzer.Text + "*))";

            DirectorySearcher Searcher = new DirectorySearcher(Entry, filter);

            var q = from s in Searcher.FindAll().OfType<SearchResult>()
                    select new
                    {
                        //GetProperty(s, "objectGUID"),
                        Benutzer = GetProperty(s, "sAMAccountName"),
                        eMail = GetProperty(s, "mail"),
                        Vorname = GetProperty(s, "givenName"),
                        Nachname = GetProperty(s, "sn"),
                        Telefon = GetProperty(s, "telephoneNumber"),
                        UserID = s.GetDirectoryEntry().NativeGuid

                    };

            this.myListView.DataSource = q;
            this.myListView.DataBind();
Run Code Online (Sandbox Code Playgroud)

现在我需要一个带GUID的过滤器,我可以在AD中找到唯一的用户.此搜索的GUID我有一个字符串UserID = Session ["UserID"].toString()

塔拉索夫

c# asp.net ldap active-directory directoryentry

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

如何使用System.DirectoryServices.AccountManagement命名空间获取Active Directory用户属性?

我想从用户获取Active Directory属性,我想使用System.DirectoryServices.AccountManagement.

我的代码:

public static void GetUserProperties(string dc,string user) 
        {
            PrincipalContext ctx = new PrincipalContext(ContextType.Domain, dc);
            UserPrincipal u = UserPrincipal.FindByIdentity(ctx, user);

            string firstname = u.GivenName;
            string lastname = u.Surname;
            string email = u.EmailAddress;
            string telephone = u.VoiceTelephoneNumber;

            ...//how I can get company and other properties?
        }
Run Code Online (Sandbox Code Playgroud)

c# properties active-directory principal userprincipal

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

我如何按列值过滤我的DataTable?

我有一个问题DataTable.我DataTable从数据库中检索一个,其中一列包含1或0.现在我只想检索该列中值为1的行.

列的名称是ACTIVATE.

这是我的DataTable:

DataTable table = new DataTable(TABLE);

//How can I filter here so ACTIVATE == 1?

adapter.Fill(table);

connection.Open();

selectcommand.ExecuteReader();

return table;
Run Code Online (Sandbox Code Playgroud)

c# asp.net datatable filter adapter

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

我如何在ASP.NET应用程序中为ListView使用ItemCommand事件

我有一个带有ListView的ASP.NET应用程序.在ListView的每一行中,我都有一个LinkBut​​ton,它打开一个新的webform"Benutzer.aspx".我的问题是我没有得到这一行的索引.我使用ItemCommand事件,但它不起作用:(

在这里我的代码:

ASPX:

...

        <ItemTemplate>

            <tr runat="server"> 

                <td align="left" ><asp:Label ID="Label1" Text='<%# Eval("Benutzer") %>' runat="server" /></td>
                <td align="left"><asp:Label ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
                <td align="left"><asp:Label ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
                <td align="left"><asp:Label ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
                <td align="left"><asp:Label ID="Label5" Text='<%# Eval("Telefon") %>' runat="server" /></td>

             <td align="left"><asp:LinkButton runat="server" Text="Anzeigen" CommandName="Anzeigen" OnCommand="ListView1_ItemCommand" CommandArgument="myArguments"></asp:LinkButton></td>

            </tr>

        </ItemTemplate>

...
Run Code Online (Sandbox Code Playgroud)

cs文件:

...

protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Anzeigen")
            {
                Label lbText = (Label)e.Item.FindControl("Label2");

               string email = lbText.Text; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net listview active-directory itemcommand

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

如何在MySQL数据库中插入数据?

我有一个ASP.NET应用程序和一个MySQL数据库.我想编写一个类来插入,删除和显示数据库中的数据.我有一个数据库连接,但我无法在数据库中插入数据.

我的类插入方法:

public string CreateEntry(string Connectionstring, string mitarbeiter)
{
    connection = new MySqlConnection(Connectionstring);
    try
    {
        var command = connection.CreateCommand();
        command.CommandText = "INSERT INTO tb_mitarbeiter (Vorname) VALUES ('tom')";
        connection.Open();
        return "Mitarbeiter wurde angelegt";
    }
    catch (Exception ex)
    {
        return ex.Message;
    }
    finally
    {
        connection.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)

Connectionstring是对的.我没有收到错误,但数据库中没有数据.

我的tablename:tb_mitarbeiter列:ID和Vorname

c# mysql database asp.net insert

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

如何使用HTML和CSS设置唯一的透明背景图像?

嗨,我想设置我的背景图像透明,其余内部不!我可以这样做吗?我使用Bootstrap ......

这是我的HTML的分裂

<!-- Startseite Section -->
    <section id="startseite" class="start-section">
        <div class="container">
            <h1><span style="opacity: 1.0;">Interne Links</span></h1>

            <div class="row">
                <div class="col-lg-12">
                    <section id="Startseite" class="pfblock">

                            <div class="row">

                             ....//Here are Elements how text and divs 

                            </div>

                    </section>
                </div>
            </div>
        </div>
    </section>
Run Code Online (Sandbox Code Playgroud)

这是CSS Split:

.start-section {
    height: 100%;
    padding-top: 150px;
    text-align: center;
    /*background: #fff;*/
    background-image:url('../img/bg.jpg');
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    opacity: 0.7;
}
Run Code Online (Sandbox Code Playgroud)

有关信息:不透明度0.7工作,但后来我透明:(

html css background opacity twitter-bootstrap

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