Pages

Subscribe:

Ads 468x60px

Tuesday, February 28, 2012

how to add style on Grid Rows in asp.net using c#

if you want to add style on Grid Rows in asp.net using c# just copy and past the below code in your .cs file.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

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

e.Row.Cells[1].Style.Add(HtmlTextWriterStyle.Position, "relative");
e.Row.Cells[1].Style.Add(HtmlTextWriterStyle.Overflow, "auto");
e.Row.Cells[1].Style.Add(HtmlTextWriterStyle.BackgroundColor, "White");
}
}

Click herefor More Solutions

how to hide or In-visible a button in asp.net using C#

if you want to hide a button in asp.net after some action here is the code
just copy and past it in your .cs file.

button1.Visible = false;

Monday, February 27, 2012

Syntax Highlighter, Code Format in Blogger

it is very Cool to highlight your code or just format your code in such a way that it should looks easy to every one and understandable to user.

here is the Code lines if you want to use Code highlighter in your BLOGGER. Just copy it and follow the steps
  • Logged on to your Blogger 
  • Go To Design Tab (it will be 4th tab if you are using new version of blogger)
  • Click on Edit HTML 
  • past the below lines before </head>
  • you have done it sucessfully.





now you only to do one thing that is
in your every post just add

<pre class="brush:[your code language]">
     your Code Goes here......
 </pre>
thats all about Code highlighter. enjoy and have fun.



How to Add new Row in a Data Grid ASP.NET using C#

Below code will check that if there is no record in Data table than it will add a new row in data Grid to show a message that there is no Record in the DataTable.
Just Copy and past the Code.
grd_abc.DataSource = ds.Tables["abc"];

            //added

            if (ds.Tables["abc"].Rows.Count < 1)
            {
                empty = true;
                ds.Tables["aging"].Rows.Add(ds.Tables["abc"].NewRow());
                grd_abc.DataSource = ds.Tables["abc"];
                grd_abc.DataBind();

                int columncount = grd_abc.Rows[0].Cells.Count;
                grd_abc.Rows[0].Cells.Clear();
                grd_abc.Rows[0].Cells.Add(new TableCell());
                grd_abc.Rows[0].Cells[0].ColumnSpan = columncount;
                grd_abc.Rows[0].Cells[0].Text = " No Record Found ";
                grd_abc.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                grd_abc.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Maroon;

            }
            else
            {
                grd_abc.DataBind();
            }