Tuesday, August 30, 2011
Tuesday, August 23, 2011
Send mail in vb.net ,desktop applicaton
Dim Mail As New MailMessage()
Mail.To.Add(New MailAddress("tomail@gmail.com"))
Mail.From = (New MailAddress("frommail@gmail.com"))
Mail.Subject = "Mail subject"
Mail.Body = "Mail body"
Mail.IsBodyHtml = True
Dim smtpClient As New SmtpClient("smtp.gmail.com")
smtpClient.Host = "smtp.gmail.com"
smtpClient.Port = 587
smtpClient.EnableSsl = True
Dim userpass As New Net.NetworkCredential("frommail@gmail.com", "frommail_password")
smtpClient.Credentials = userpass
smtpClient.Send(Mail)
MessageBox.Show("Mail Send")
Mail.To.Add(New MailAddress("tomail@gmail.com"))
Mail.From = (New MailAddress("frommail@gmail.com"))
Mail.Subject = "Mail subject"
Mail.Body = "Mail body"
Mail.IsBodyHtml = True
Dim smtpClient As New SmtpClient("smtp.gmail.com")
smtpClient.Host = "smtp.gmail.com"
smtpClient.Port = 587
smtpClient.EnableSsl = True
Dim userpass As New Net.NetworkCredential("frommail@gmail.com", "frommail_password")
smtpClient.Credentials = userpass
smtpClient.Send(Mail)
MessageBox.Show("Mail Send")
Friday, August 19, 2011
Thursday, August 18, 2011
get gridview rowindex commandargument
delete a perticular row by rowindex
protected void grdRoomNumber_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
grdRoomNumber.DeleteRow(Convert.ToInt32(e.CommandArgument));
}
}
Sunday, August 7, 2011
RANDOM DATATABLE ROW
static Random _rand = new Random();
public DataView RandomizeDataTable(DataTable dt)
{
// Create array of indices and populate with ordinal values
int[] indices = new int[dt.Rows.Count];
for (int i = 0; i < indices.Length; i++)
indices[i] = i;
// Knuth-Fisher-Yates shuffle indices randomly
for (int i = indices.Length - 1; i > 0; i--)
{
int n = _rand.Next(i + 1);
int tmp = indices[i];
indices[i] = indices[n];
indices[n] = tmp;
}
// Add new column to data table (if it's not there already)
// to store shuffle index
if (dt.Columns["rndSortId"] == null)
dt.Columns.Add(new DataColumn("rndSortId", typeof(int)));
int rndSortColIdx = dt.Columns["rndSortId"].Ordinal;
for (int i = 0; i < dt.Rows.Count; i++)
dt.Rows[i][rndSortColIdx] = indices[i];
DataView dv = new DataView(dt);
dv.Sort = "rndSortId";
return dv;
}
public DataView RandomizeDataTable(DataTable dt)
{
// Create array of indices and populate with ordinal values
int[] indices = new int[dt.Rows.Count];
for (int i = 0; i < indices.Length; i++)
indices[i] = i;
// Knuth-Fisher-Yates shuffle indices randomly
for (int i = indices.Length - 1; i > 0; i--)
{
int n = _rand.Next(i + 1);
int tmp = indices[i];
indices[i] = indices[n];
indices[n] = tmp;
}
// Add new column to data table (if it's not there already)
// to store shuffle index
if (dt.Columns["rndSortId"] == null)
dt.Columns.Add(new DataColumn("rndSortId", typeof(int)));
int rndSortColIdx = dt.Columns["rndSortId"].Ordinal;
for (int i = 0; i < dt.Rows.Count; i++)
dt.Rows[i][rndSortColIdx] = indices[i];
DataView dv = new DataView(dt);
dv.Sort = "rndSortId";
return dv;
}
Tuesday, August 2, 2011
Subscribe to:
Posts (Atom)