So the problem is that the grid view's children tree is very, very
complex. FindControl isn't smart enough to search through it all, and
even if it was, it wouldn't know which row you were talking about.
When you bind the data grid you could potentially have 100s of rows,
there would be no way for FindControl to know which row you were
talking about.
This is the solution:
<EditItemTemplate>
<asp:TextBox ID="txtURL" runat="server"
Text='<%#Eval("URL")%>' Visible='<%# Eval("Type").ToString() !=
"Internal" %>'></asp:TextBox>
</EditItemTemplate>
Please excuse any syntax errors, I typed this in gmail (the syntax
highlighting, and C# compiler in gmail/goolge chrome isn't so great...
haha).
There are a couple of other ways that you could approach this problem,
but I think this will be the most succinct, and clean way of doing it.
Everything else I can think of requires more code.
On Sep 4, 3:44 am, Sreenivas <
thatiparthysreeni...@gmail.com> wrote:
> Hi,
> my program contains onegridview.gridviewhas dropdown list and
> text as two columns.
> drop down contains only 2 items..that are "Internal" and "External".If
> select Internal the Text box
> should be set to invisible...
> Here goes my code..
> =============================================================
> <asp:GridViewID="gvNews" runat="server" AutoGenerateColumns="False"
> OnRowCancelingEdit="gvNews_RowCancelingEdit"
> OnRowEditing="gvNews_RowEditing" AllowPaging="True"
> OnRowUpdating="gvNews_RowUpdating"
> OnPageIndexChanging="gvNews_PageIndexChanging"
> CssClass="bdytxt" BorderColor="LightSteelBlue"
> CellPadding="3" OnRowDataBound="gvNews_RowDataBound">
> <HeaderStyle CssClass="menutxt" BackColor="SteelBlue" /
>
> <Columns>
> <asp:TemplateField HeaderText="Id">
> <ItemTemplate>
> <asp:Label ID="lblNewsId" runat="server"
> Text='<%#Bind("NewsId")%>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Title">
> <ItemTemplate>
> <asp:Label ID="lblTitle" runat="server"
> Text='<%#Bind("Title")%>'></asp:Label>
> </ItemTemplate>
> <EditItemTemplate>
> <asp:TextBoxID="txtTitle" runat="server"
> Text='<%#Eval("Title")%>'></asp:TextBox>
> <asp:RequiredFieldValidator ID="rvTitle"
> ControlToValidate="txtTitle" runat="server"
> ErrorMessage="Title required">
> </asp:RequiredFieldValidator>
> </EditItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Description">
> <ItemTemplate>
> <asp:Label ID="lblDescription"
> runat="server" Text='<%#Bind("Description")%>'>
> </asp:Label>
> </ItemTemplate>
> <EditItemTemplate>
> <asp:TextBoxID="txtDescription"
> <asp:TextBoxID="txtURL" runat="server"
> //TextBoxtxtUrl = (TextBox)