views:

49

answers:

3
+1  Q: 

GridView Control

First of all sory for my English.

I have a grid control. And I want to access gridview child control from other controls.

Ex:

<asp:UpdatePanel ID="upPersonelAssignment" runat="server">
<ContentTemplate>
        <asp:Label ID="lblPersonelName" runat="server" ></asp:Label>
        <asp:Label ID="lblUpdatedDateTime" runat="server" ></asp:Label>
        <div id="divPersonelAssignmentSearch">
            <asp:GridView ID="gvPersonelAssignment" runat="server" DataSourceID="odsPersonelBLL" 
                AllowSorting="True" AutoGenerateColumns="False" 
                onrowdatabound="GridView1_RowDataBound">
                <Columns>
                    <asp:CommandField CancelText="Vazgeç" EditText="Amir Ata" ShowEditButton="True" 
                        UpdateText="Amir Kaydet" />
                    <asp:TemplateField HeaderText="Sicil No">
                        <ItemTemplate>
                            <asp:Label ID="lblPersonelSicilNo" runat="server"  Text='<%# Eval("personelSicil") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="İsim">
                        <ItemTemplate>
                            <asp:Label ID="lblPesonelFirstName" runat="server" Text='<%# Eval("personelAdi") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField> ...
...........
                    <asp:TemplateField HeaderText="Amir Liste">
                        <ItemTemplate>
                            <asp:Label ID="lblAmirList" runat="server" Text="Amir Liste"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
...........

        <div id="divDropDownExtender" runat="server">
            <act:DropDownExtender ID="ddeAmirList" runat="server" 

            TargetControlID="lblAmirList" DropDownControlID="">

            </act:DropDownExtender>
        </div>

But I have error : The TargetControlID of 'ddeAmirList' is not valid. A control with ID 'lblAmirList' could not be found

How to I access grid view child control from other control.

Thanks for help.

A: 

have a look at this post:

http://www.codeproject.com/KB/dotnet/AccessingControlsInsideGr.aspx

Tony
A: 

Hey,

You have to put extenders within the GridView control for this to work, within the template of the control.

Brian
A: 

using the ondatabound even of the gridview

you can access the control inside your gridview by writing the following:

protected void YourGridView_DataBound(object sender, EventArgs e)
{
    Label label1 = (Label)e.Row.Cells[0].FindControl("lblAmirList");
    // access your control
    label1.Text = "sdfs";

    // do this for other controls inside gridview

}
peacmaker