Tuesday, June 19, 2012

How To Customize Gridview Inbuild Templates


Example:
=======
 grvDynamicResult.Templates.EmptyDataRow = new SimilarSearchTemplate ();

SimilarSearchTemplate.cs
==================
    public class SimilarSearchTemplate : ITemplate
    {

        
        public SimilarSearchTemplate()
        {

          

        }

        public void InstantiateIn(Control container)
        {

            Table table = new Table();
            table.Style.Add( "width", "100%" );
            table.Style.Add( "text-align", "center" );
            TableRow tr = new TableRow();
             TableRow tr2 = new TableRow();

          
            HyperLink lnkShowPhoneticSearch = new   HyperLink ();
                lnkShowPhoneticSearch.Text = "Click here to get similar Records." ;
              
                lnkShowPhoneticSearch.Style.Add( "cursor", "pointer" );

                 Label lblNoData = new Label ();
                lblNoData.Text = "No data to display";
                TableCell cell = new TableCell();
                cell.Controls.Add(lnkShowPhoneticSearch);

                TableCell cell1 = new TableCell();
                cell1.Controls.Add(lblNoData);
                tr.Cells.Add(cell);
                tr2.Cells.Add(cell1);

             
                table.Rows.AddAt(0, tr);
                table.Rows.AddAt(0, tr2);

            container.Controls.Add(table);
        }
    }

No comments:

Post a Comment