how to find control using in c#

default.aspx
  1.  <asp:GridView ID="gvproperty" runat="server" AllowPaging="false" AutoGenerateColumns="false" Width="100%"
                        ShowHeader="false">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Label ID="lblname" runat="server" Text='<%# Eval("p_name") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:HiddenField ID="hdnvalue" runat="server" Value='<%#Eval("p_id") %>' />
                                    <asp:CheckBox ID="chkvalue" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
 default.aspx.cs

string inwor_property = string.Empty;
            if (gvproperty.Rows.Count > 0)
            {
                for (int i = 0; i < gvproperty.Rows.Count; i++)
                {
                    GridViewRow row = (GridViewRow)gvproperty.Rows[i];
                    CheckBox chkvalue = (CheckBox)row.FindControl("chkvalue");
                    Label lblpname = (Label)row.FindControl("lblname");
                    HiddenField hdnvalue = (HiddenField)row.FindControl("hdnvalue");
                    if (chkvalue.Checked)
                    {
                        linq_obj.I_mst_inword_property(Convert.ToInt32(ddlptype.SelectedValue), Convert.ToInt32(hdnvalue.Value));
                        linq_obj.SubmitChanges();
                        inwor_property = inwor_property + lblpname.Text + ",";
                        chkvalue.Checked = false;
                    }
                }
            }

Comments ( 0 )