In my last project i want to calculate only those rows who display in grid not all.

when i am using MyGrid.RowCount or MyGrid.Rows.Count it gives me all rows..

Finally i find event DisplayedRowCount

Here is sample

public int DisplayedRowCount(
bool includePartialRow
Parameter : includePartialRow
true to include partial rows in the displayed row count; otherwise, false.

Int32 count = DisplayedRowCount(true);
Int32 count1 = DisplayedRowCount(false);

count return all row count
count1 return all visible row count..


Byte Array to Image Conversion

Convert byte[] array to Image

public Image byteArrayToImage(byte[] byteArrayIn)
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;

Image to Byte Array conversion

Convert Image to byte[] array:

public byte[] imageToByteArray(System.Drawing.Image imageIn)
MemoryStream ms = new MemoryStream();
return ms.ToArray();

301 permanent redirects and ASP.Net 4.0

Hello all,

In this post, I would like to talk about a new method of the Response object that comes with ASP.Net 4.0.

The name of the method is RedirectPermanent.

Let’s talk a bit about 301 redirection and permanent redirection.301 redirect is the most efficient and Search Engine Friendly method for webpage redirection.

Let’s imagine that we have this scenario. This is a very common scenario. We have redesigned and move folders to some pages that have high search engine rankings. We do not want to lose those rankings.

We can permanently redirect traffic to the new pages without losing page rankings by using the 301 permanent redirect. RedirectPermanent help us to achieve that.

In order to demonstrate this new helper method, I will create the default website that comes with 4.0.

1) Fire VS 2010 and create a new website. Choose the filesystem to save your website ann VB as the .net language for this website

This is a much richer template that the previous ones that were created with VS 2008.

We have a Home page and an About page.

2) Create a new page and call it NewAbout (NewAbout.aspx)

3) Write some dummy content on it like “This is our new About us page”

4) Move to the About.aspx.vb, and in the page load event, type the following

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

5)  Now run your application and then click “About” page. You will permanently redirect to the new “NewAbout” page.

Hope it helps!!!!

Update windows form from child to parent

we are opening child forms and doing some calculation.after finished the calculation in child form. whatever changes we made it should be reflected immediately in the main form.for that I am used event handler to update the main form.

public partial class Form1 : Form
public Form1()
private void button1_Click(object sender, EventArgs e)
Form2 frm2 = new Form2();
//Wired Up Here
frm2.RefreshMain += new EventHandler(frm2_RefreshMain);
void frm2_RefreshMain(object sender, EventArgs e)
//Write your logic here to update datagridview
private DataSet CreateDataSet()
DataTable table = new DataTable(“childTable”);
DataColumn column;
DataRow row;
DataSet dataset = new DataSet();
// Create first column and add to the DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType(“System.Int32”);
column.ColumnName = “CustID”;
column.AutoIncrement = true;
column.Caption = “ID”;
column.ReadOnly = true;
column.Unique = true;
// Add the column to the DataColumnCollection.
//// Create second column.
column = new DataColumn();
column.DataType = System.Type.GetType(“System.String”);
column.ColumnName = “CustName”;
column.AutoIncrement = false;
column.Caption = “Name”;
column.ReadOnly = false;
column.Unique = false;
for (int i = 0; i <= 100; i++)
row = table.NewRow();
row[“CustID”] = i;
row[“CustName”] = “Item ” + i;
return dataset;
DataSet dsCust;
private void BindData()
dsCust = CreateDataSet();
dataGridView1.DataSource = dsCust.Tables[0];

private void Form1_Load(object sender, EventArgs e)


//Code For Form 2

public partial class Form2 : Form{

//Declare event handler here
public event EventHandler RefreshMain;
public Form2()

private void Form2_Load(object sender, EventArgs e)


protected void UpdateMain()
if (RefreshMain != null)
RefreshMain(this, EventArgs.Empty);

private void Form2_FormClosing(object sender, FormClosingEventArgs e)


%d bloggers like this: