0
我希望將「tdate」格式設置爲「d,MMM,yyyy」,然後將其從具有數據網格視圖的窗體發送到包含文本框的其他窗體。將日期時間格式從一種格式更改爲另一種格式
到目前爲止,我試圖使它爲:
frm.txtDate.Text = (this.dgvEvents.CurrentRow.Cells[2].Value.ToString("d, MMM, yyyy"));
這是類的代碼: -
public int CreateTicket(string tName, DateTime tDate, string type, string venue)
{
EventTicketEntities database = new EventTicketEntities();
Ticket t = new Ticket();
t.TicketName = tName;
t.TicketDate = tDate;
t.TicketType = type;
t.TicketVenue = venue;
database.Tickets.Add(t);//We ADD our promoter to our advertiser table!
return database.SaveChanges(); //returns the affected rows ....
}
而且這個代碼是展現出新的形式時,「繼續」按鈕被點擊。
public void btnProceed_Click(object sender, EventArgs e)
{
ticketForm frm = new ticketForm();
frm.txtName.Text = (this.dgvEvents.CurrentRow.Cells[1].Value.ToString());
frm.txtDate.Text = (this.dgvEvents.CurrentRow.Cells[2].Value.ToString());
frm.txtType.Text = (this.dgvEvents.CurrentRow.Cells[3].Value.ToString());
frm.txtVenue.Text = (this.dgvEvents.CurrentRow.Cells[4].Value.ToString());
//pass selected index of combobox
frm.Show();
}
完美,只是完美!謝謝Habib先生! – HurpaDerpa