我的时间是16:23:01.我尝试过使用DateTime.ParseExact
,但它没有用.
这是我的代码:
string Time = "16:23:01";
DateTime date = DateTime.ParseExact(Time, "hh:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture);
lblClock.Text = date.ToString();
Run Code Online (Sandbox Code Playgroud)
我希望它在标签上显示为04:23:01 PM.
我有以下问题,我使用SQL Server MS,下面是我的结果.它看起来很简单,但我无法弄明白.
我的查询:
SELECT RIGHT(CONVERT(VARCHAR(26), Timein, 109), 14) from vwSignIn
Run Code Online (Sandbox Code Playgroud)
会给我这个9:12:16:597AM
我希望这是我的结果9:12:16 AM.
提前致谢.
我在ASP.net中有Gridview显示数据.根据数据,它会根据单元格的值更改颜色和文本.当列不是模板字段时,这可以正常工作.
//WORKS WHEN IS NOT A TEMPLATE FIELD
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[2].Text == "1")
{
e.Row.Cells[2].Text = "IN";
e.Row.Cells[2].BackColor = Color.Blue;
e.Row.Cells[2].ForeColor = Color.White;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我将Column转换为Template字段,但没有任何效果.
//DOEST NOT WORK WHEN IS a TEMPLATE FIELD
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[2].Text == "1")
{
e.Row.Cells[2].Text = "IN";
e.Row.Cells[2].BackColor = Color.Blue;
e.Row.Cells[2].ForeColor = Color.White;
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了颜色工作,但现在我需要将文本更改为以下内容.IF statusID == 1然后显示IN,否则如果statusID == 2则显示OUT
<asp:TemplateField HeaderText="StatusID" SortExpression="StatusID">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue = '<%# Bind("StatusID") %>'>
<asp:ListItem Value="1">IN</asp:ListItem>
<asp:ListItem …
Run Code Online (Sandbox Code Playgroud) 我有一个gridviewMain.每当我单击第1行的CLOSE linkbutton时,我想获得值aa.单击第2行上的关闭获取bb的值.有任何想法吗.
A B C
aa xx 3 CLOSE
bb yy 4 CLOSE
cc zz 5 CLOSE
Run Code Online (Sandbox Code Playgroud)
ASPX
<asp:BoundField DataField="afield" HeaderText="A"
SortExpression="afield" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="bfield" HeaderText="B" SortExpression="cfield" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="cfield" HeaderText="C" SortExpression="cfield" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lbClose" runat="server" CausesValidation="False" CommandName="CloseClicked" Text="Close"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud) 我有一个包含一些ID的List.我想从DataTable中删除行= ListLinkedIds
List<string> ListLinkedIds = new List<string>(); //This has values such as 6, 8, etc.
DataSet ds = new DataSet();
SqlDataAdapter da = null;
DataTable dt = new DataTable();
da = new SqlDataAdapter("SELECT TicketID, DisplayNum, TranstypeDesc, SubQueueId, EstimatedTransTime,LinkedTicketId FROM vwQueueData WHERE (DATEADD(day, DATEDIFF(day, 0, Issued), 0) = DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)) AND QueueId = @QueueId AND SubQueueId = @SubQueueId AND LinkedTicketId != @LinkedTicketId AND Called IS NULL", cs);
da.SelectCommand.Parameters.AddWithValue("@QueueId", Queue);
da.SelectCommand.Parameters.AddWithValue("@SubQueueId", SubQueue);
da.SelectCommand.Parameters.AddWithValue("@LinkedTicketId", ListLinkedIds[x]);
da.Fill(ds);
//Removes from DataTable
for …
Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET应用程序,员工登录到Windows,然后他们必须从一长串名称中选择他们的名字并登录到应用程序.
我想要做的是,一旦员工打开应用程序,它就会从下拉框中选择他们的名字.
我相信如果我可以在页面加载时获得Windows用户ID,那么我可以根据登录的Windows用户使我的代码选择用户.
问题是.如何获得当前登录C#Asp.net的Windows用户ID?有任何想法吗.
我有一个包含 zip 文件的 URL。需要从 URL 中解压缩文件。使用 webclient 打开和读取 URL,然后将其添加到流中。然后在 ZipArchive 对象中使用它,该对象将解压缩文件并将它们存储在 D:\ 驱动器中。当文件大小约为 400Mb 时,我会收到'System.OutOfMemoryException'。
由于 webClient.OpenRead(Uri Address) 返回一个 Stream,因此必须使用 Stream。以及使用ZipArchive(Stream流)。
我怎样才能停止收到此消息?
string zipFileUrl = "https://www.dropbox.com/s/clersbjdcshpdy6/oversize_zip_test_0.zip?dl=0"
string output_path = @"D:\";
using (WebClient webClient = new WebClient())
{
using (Stream streamFile = webClient.OpenRead(zipFileUrl))
{
using (ZipArchive archive = new ZipArchive(streamFile))//ERROR HERE
{
var entries = archive.Entries;
//Loops thru each file in Zip and adds it to directory
foreach (var entry in entries)
{
if (entry.FullName != "/" && entry.Name …
Run Code Online (Sandbox Code Playgroud) 我有这个:
StringBuilder sb = new StringBuilder(time.Text);
if (DateTime.Parse(time.Text) > DateTime.Parse("12:00:00 AM")
&& DateTime.Parse(time.Text) < DateTime.Parse("11:59:59 AM"))
{
time.Text = time.Text + " AM";
}
else
{
time.Text = time.Text + " PM";
}
Run Code Online (Sandbox Code Playgroud)
我现在的情况是下午16:34,
我希望它在04:34 PM显示
我的程序动态创建按钮.
private void CreateButton(string buttonName)
{
Color[] c = { Color.Red, Color.Teal, Color.Blue, Color.WhiteSmoke };
transbutton = new Button();
transbutton.BackColor = c[2];
transbutton.Text = buttonName;
transbutton.Name = buttonName + "Button";
transbutton.Width = 150;
transbutton.Height = 150;
transbutton.Font = new Font("Segoe UI", 13);
transbutton.ForeColor = Color.White;
transbutton.Click += new EventHandler(transbutton_Click);
}
private void transbutton_Click(object sender, EventArgs e)
{
tbList.Text = transbutton.Text;
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是当用户点击按钮时,它将按钮的名称添加到多行TextBox中,如上图所示.我创建了一个EventHandler,但无法弄清楚如何使它与动态按钮一起使用.
我有以下数据,它从两个检索textbox
.我想按时间降序排序.我尝试使用词典,但我无法插入重复的值.有任何想法吗?
ID time ID time
4 10 15 19
12 13 WANT SORTED BY TIME 12 13
15 19 ---->> 12 13
4 10 4 10
12 13 4 10
Run Code Online (Sandbox Code Playgroud)