Hi,
We can create DataTable dynamically and display the content either in GridView or DataList or in Repeater.
DataTable dataTable = new DataTable();
DataRow dataRow;
dataTable.Columns.Add(new DataColumn("Title", typeof(string)));
dataTable.Columns.Add(new DataColumn("Description", typeof(string)));
dataTable.Columns.Add(new DataColumn("Author", typeof(string)));
if (_post != null)
{
dataRow = dataTable.NewRow();
dataRow[0] = _post.Title;
dataRow[1] = _post.Description;
dataRow[2] = _user.DisplayName;
dataTable.Rows.Add(dataRow);
}
myDataList.DataSource = dataTable;
myDataList.DataBind();
Thursday, January 22, 2009
Wednesday, January 21, 2009
To Convert HTML Text to Normal Text
Hi,
If you want to remove the html tag from the text and replace as normal text use the following coding in Javascript.
using System.Text.RegularExpressions;
private string StripTags(string HTML)
{
// Removes tags from passed HTML
Regex objRegEx = new Regex("<[^>]*>");
return objRegEx.Replace(HTML, "");
}
If you want to remove the html tag from the text and replace as normal text use the following coding in Javascript.
using System.Text.RegularExpressions;
private string StripTags(string HTML)
{
// Removes tags from passed HTML
Regex objRegEx = new Regex("<[^>]*>");
return objRegEx.Replace(HTML, "");
}
Friday, December 26, 2008
To avoid overflow of div without using overflow:hidden
Hi,
If you are using div. Sometimes the div may overflow in IE6 browser.This is due to nesting of various div.So check the div top position.If u find placing of any div, overflows the existing div. Plz change the top to margin-top property to avoid overflow of particular div.
If you are using div. Sometimes the div may overflow in IE6 browser.This is due to nesting of various div.So check the div top position.If u find placing of any div, overflows the existing div. Plz change the top to margin-top property to avoid overflow of particular div.
Friday, December 19, 2008
Refresh() method in Windows Application
Hi,
Refresh() -Forces the control to Invalidate its client area and Immediately redraw itself and its child control.
we can use either Refresh() or invalidate() methods to redraw the client area with the updated position. If you want to drag an image inside the picturebox,you must use any one of these methods.
Refresh() -Forces the control to Invalidate its client area and Immediately redraw itself and its child control.
we can use either Refresh() or invalidate() methods to redraw the client area with the updated position. If you want to drag an image inside the picturebox,you must use any one of these methods.
Wednesday, December 17, 2008
To get ShortMonth in C#.net
Hi,
Use the below coding to get the short month,
public static string GetShortMonth(object aDate)
{
DateTime actualDate = (DateTime)aDate;
int day = actualDate.Day;
int monthNumber = actualDate.Month;
string month = "";
if (monthNumber == 1)
{
month = "Jan,";
}
else if (monthNumber == 2)
{
month = "Feb,";
}
else if (monthNumber == 3)
{
month = "Mar,";
}
else if (monthNumber == 4)
{
month = "Apr,";
}
else if (monthNumber == 5)
{
month = "May,";
}
else if (monthNumber == 6)
{
month = "Jun,";
}
else if (monthNumber == 7)
{
month = "Jul,";
}
else if (monthNumber == 8)
{
month = "Aug,";
}
else if (monthNumber == 9)
{
month = "Sep,";
}
else if (monthNumber == 10)
{
month = "Oct,";
}
else if (monthNumber == 11)
{
month = "Nov,";
}
else if (monthNumber == 12)
{
month = "Dec,";
}
int year = actualDate.Year;
return month + " " + day.ToString() + " " + year.ToString();
}
Use the below coding to get the short month,
public static string GetShortMonth(object aDate)
{
DateTime actualDate = (DateTime)aDate;
int day = actualDate.Day;
int monthNumber = actualDate.Month;
string month = "";
if (monthNumber == 1)
{
month = "Jan,";
}
else if (monthNumber == 2)
{
month = "Feb,";
}
else if (monthNumber == 3)
{
month = "Mar,";
}
else if (monthNumber == 4)
{
month = "Apr,";
}
else if (monthNumber == 5)
{
month = "May,";
}
else if (monthNumber == 6)
{
month = "Jun,";
}
else if (monthNumber == 7)
{
month = "Jul,";
}
else if (monthNumber == 8)
{
month = "Aug,";
}
else if (monthNumber == 9)
{
month = "Sep,";
}
else if (monthNumber == 10)
{
month = "Oct,";
}
else if (monthNumber == 11)
{
month = "Nov,";
}
else if (monthNumber == 12)
{
month = "Dec,";
}
int year = actualDate.Year;
return month + " " + day.ToString() + " " + year.ToString();
}
To Get ShortDate in C#.net
Hi,
we can get the ShortDate using the following function,
public string GetShortDate(object aDate)
{
DateTime actualDate = (DateTime)aDate;
string shortDate = "";
string month = actualDate.ToLongDateString();
string[] mon = month.Split(',');
string date = mon[1];
string year = mon[2];
shortDate = date + year;
return shortDate;
}
we can get the ShortDate using the following function,
public string GetShortDate(object aDate)
{
DateTime actualDate = (DateTime)aDate;
string shortDate = "";
string month = actualDate.ToLongDateString();
string[] mon = month.Split(',');
string date = mon[1];
string year = mon[2];
shortDate = date + year;
return shortDate;
}
To GetSubString in C#.net
Hi,
We can reduce the length of the string using getSubString function, so that the length of the string is reduced to our required length.
public string GetSubString(Object str,int len)
{
string name="";
name=str+"";
if(name.Length>len)
{
name=name.Substring(0,len);
}
return name;
}
We can reduce the length of the string using getSubString function, so that the length of the string is reduced to our required length.
public string GetSubString(Object str,int len)
{
string name="";
name=str+"";
if(name.Length>len)
{
name=name.Substring(0,len);
}
return name;
}
Subscribe to:
Posts (Atom)
