Friday, April 29, 2011

how to append text in literal control using c#


dynamic generation of text boxes in button click using c#

static int i=0;

protected void Button2_Click(object sender, EventArgs e)
{
n++;


int i = 0;

TextBox[] tb = new TextBox[n + 1];

for (i = 0; i <= n - 1; i++)
{

tb[i] = new TextBox();
dynsmicpnl.Controls.Add(tb[i]);
dynsmicpnl.Controls.Add(new LiteralControl("
"));

}
}

Tuesday, April 26, 2011

How to Write Case statements in sql view

CREATE view [dbo].[vwcall_master]
as
select
case when Call_Duration is null then 'Enter duration' else Call_Duration end as Call_Duration,
case when Call_To_NumberExtn is null then '00000000' else Call_To_NumberExtn end as Call_To_NumberExtn,
case when Client_Id is null then '0' else Client_Id end as Client_Id,
case when Client_Name is null then ' Enter Clientname' else Client_Name end as Client_Name,

Call_Id,
User_Id,
Call_From_UserName,
Call_From_NumberExtn,
Call_DateTime,
UpLoade_Audio_Call,
Rating,
Rating_UserId
from call_master

Wednesday, April 20, 2011

How to convert ist to est in c#

DateTime time1 = new DateTime(2011,04,20,17,57,33);
// DateTime time1 = new DateTime();// your DataTimeVariable

TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

DateTime newTime = TimeZoneInfo.ConvertTime(time1, timeZone1, timeZone2);
Response.Write(newTime);

Saturday, April 16, 2011

How to use file system writer in c#

FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\\Documents and Settings\\bosco\\Desktop\\system";
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);

// Begin watching.
watcher.EnableRaisingEvents = true;

}
protected void OnChanged(object sender, FileSystemEventArgs e)
{

string str = e.FullPath;
string[] str1=str.Split('\\');
// Specify what is done when a file is changed, created, or deleted.
MessageBox.Show("File: " + e.FullPath + " " + e.ChangeType);
MessageBox.Show(str1[0] + "," + str1[1] + "," + str1[2]);
// Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
}

protected void OnRenamed(object sender, RenamedEventArgs e)
{
// Specify what is done when a file is renamed.


//Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
MessageBox.Show("File: " + e.FullPath + " " + e.ChangeType);

}

Thursday, April 7, 2011

how to set attributes in the asp.net tool elements

private void buildcboAuthors()
{
OleDbCommand cmd = new OleDbCommand("SELECT * FROM tblAuthors",conn);
this.conn .Open ();
OleDbDataReader rsAutors = cmd.ExecuteReader();
ArrayList Authors = new ArrayList();

while(rsAutors.Read())
{
Authors.Add (new AddValue
(rsAutors.GetString(1),rsAutors.GetInt32 (0)));

}
rsAutors.Close();
this.conn.Close();

this.cboAuthors.DataSource = Authors;
this.cboAuthors .DisplayMember ="Display";
this.cboAuthors.ValueMember = "Value";
AuthorsHaveBeenAdded=true;
}