Saturday, 15 November 2014

Get Controls type inside Gridview in asp.net code behind

//HTML
<asp:GridView ID="GridView1" runat="server" ></asp:GridView>

//C#
foreach (Control clt in GridView1.Rows[0].Controls)
                {
                    foreach (Control clt1 in clt.Controls)
                    {
                        if (clt1 is TextBox)
                        {
                            ((TextBox)clt1).BackColor = validateColor;
                        }
                        else if (clt1 is DropDownList)
                        {
                            ((DropDownList)clt1).BackColor = validateColor;
                        }
                    }
                }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...