Sunday, May 11, 2025

Breaking News
>> Securing and encrypt View State and Cookies values  >> Page has one or more controls that do not correspond with   >> “The Controls collection cannot be modified because the control contains code blocks”  >> How to fix "Validation(): Element 'xxxx' is not supported  >> How to create a new session in ASP.NET programmatically  >> MySQL Database Backup using mysqldump command    

Editors Picks

Friday, February 25, 2011

Find Controls inside GridView


Find Controls inside GridView



// grid view defination
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="PapayaWhip"  BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" Font-Names="Tahoma" Height="16px"
Width="928px">
<Columns>
<asp:TemplateField>
<HeaderTemplate>HeadingHeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="text_box1" runat="server">asp:TextBox>
ItemTemplate>
asp:TemplateField>
asp:GridView>


//code for accessing value of text_box1 inside the GridView1

  for(int i = 0;i<GridView1.Rows.Count; i++)
  {
    TextBox t1;
    t1 = (TextBox)GridView1.Rows[n].FindControl("text_box1");
    Response.Write(t1.Text);
  }

No comments :

Post a Comment

Contact Us

Name

Email *

Message *