Thursday, January 28, 2010

Gridview Theme css not working in ie8

Put following in <head> in your masterpage or in aspx.
 
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
 

Monday, January 11, 2010

How to stop repeat in column value using datagrid C#?

How to stop repeat in column value using datagrid C#?
descr1 dsesc2 value
abc      xxxx    100
           yyyy     200
mno     xxxx    1000
                       5000
            yyyy      100 
I did following:
global variable:
       string acc5;
       string acc6;

  public void productsGridView_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
     {
        if ((e.Row.RowType == DataControlRowType.DataRow))
        {

 acc6 = e.Row.Cells[2].Text;
            if (e.Row.Cells[2].Text == acc5)
            {
                acc6 = e.Row.Cells[2].Text;
                e.Row.Cells[2].Text = "";
            }
            acc5 = acc6;
 }
    }

Thursday, January 7, 2010

Insert Dynamic Rows in Gridview


in row  RowDataBound use this code

 Table tbl = e.Row.Parent as Table;
            if (tbl != null)
            {
                GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
                TableCell cell = new TableCell();
                HtmlGenericControl span = new HtmlGenericControl("span");
                span.InnerHtml = "Insert Row";
                cell.Controls.Add(span);
                row.Cells.Add(cell);
                tbl.Rows.AddAt(tbl.Rows.Count - 1, row);

            }