Saturday 29 June 2013

Simple Delegete Example in C#

using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;

namespace
ConsoleApplication1
{
public delegate void delegate_sajil();
class Program
{
public static void sajil()
{
Console.WriteLine("I Called One Delegate!");
Console.ReadLine();
}
static void Main(string[] args)
{
delegate_sajil obj = new delegate_sajil(sajil);
obj();
}
}
}

Tuesday 18 June 2013

Row Wise Summary in Gridview Asp.net

protected void gvdashboard_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow){

DataRowView drv = (DataRowView)e.Row.DataItem;
if (tmpCategoryName1 != drv["Description"].ToString()){
tmpCategoryName1 = drv[
"Description"].ToString();
// Get a reference to the current row's Parent, which is the Gridview (which happens to be a table)
Table tbl = e.Row.Parent as Table;
if (tbl != null){
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
TableCell cell = new TableCell();
// Span the row across all of the columns in the Gridview//cell.ColumnSpan = this.GridView1.Columns.Count;cell.ColumnSpan = 10;
// cell.Width = Unit.Percentage(100);cell.Height = Unit.Percentage(100);
// cell.Width = Unit.Percentage(100);cell.Style.Add("font-family", "verdana");cell.Style.Add(
"font-size", "11px");cell.Style.Add(
"font-weight", "bold");cell.Style.Add(
"color", "#FFF");cell.Style.Add(
"background-color", "#5A83C3");cell.Style.Add(
"text-align", "Left");
DataTable GetCount = new DataTable();GetCount = (
DataTable)ViewState["Gvdashboard"];
object sumObject;
sumObject = GetCount.Compute(
"Count(Description)", "Description = '" + tmpCategoryName1+ "'");
GetCount.Dispose();

HtmlGenericControl span = new HtmlGenericControl("span");span.InnerHtml = tmpCategoryName1 +
"-(" + sumObject + ")";cell.Controls.Add(span);
row.Cells.Add(cell);
tbl.Rows.AddAt(tbl.Rows.Count - 1, row);
}
}
}
}