I have a radgrid as below.
<telerik:RadGrid runat="server" ID="gridEconomist" EnableViewState="true" AllowPaging="true" OnNeedDataSource="gridEconomist_NeedDataSource"
OnItemCommand="gridEconomist_ItemCommand" OnItemDataBound="gridEconomist_ItemDataBound" AutoGenerateColumns="false" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AutoGenerateEditColumn="false"
AutoGenerateDeleteColumn="false" >
<MasterTableView AutoGenerateColumns="false" EnableViewState="true" EditMode="InPlace" DataKeyNames="assignedTo" NoDetailRecordsText="No Vouchers Found"
CommandItemDisplay="none">
<Columns>
<telerik:GridTemplateColumn UniqueName="VoucherCode" HeaderText="Voucher Code" DataField="VoucherCode">
<ItemTemplate>
<asp:Label ID="lblCode" runat="server" Enabled="true" Text='<%# Eval( "VoucherCode" )%>'>
</asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="createdDate" HeaderText="Created Date" DataField="createdDate">
<ItemTemplate>
<asp:Label ID="lblCreatedDate" runat="server" Enabled="false" Text='<%# Eval( "createdDate" )%>'>
</asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="assignedTo" HeaderText="Assigned To" DataField="assignedTo">
<ItemTemplate>
<asp:Label ID="lblAssgTo" runat="server" Text='<%# Eval( "assignedTo" )%>'>
</asp:Label>
<asp:TextBox ID="txtAssgTo" runat="server" Visible="false" Text='<%# Eval( "assignedTo" )%>'>
</asp:TextBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="assignedDate" HeaderText="Assigned Date" DataField="assignedDate">
<ItemTemplate>
<asp:Label ID="lblAssgDate" runat="server" Enabled="false" Text='<%# Eval( "assignedDate" )%>'>
</asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="organization" HeaderText="Organization" DataField="organization">
<ItemTemplate>
<asp:Label ID="lblorganization" runat="server" Enabled="false" Text='<%# Eval( "organization" )%>'>
</asp:Label>
<asp:DropDownList CssClass="fontEIS" Visible="false" ID="ddlorganization" runat="server">
<asp:ListItem Value="IMF">IMF</asp:ListItem>
<asp:ListItem Value="WB">WB</asp:ListItem>
<asp:ListItem Value="IFC">IFC</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Edit" HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/Edit.jpg" Width="10px" Height="10px" CommandName="Edit" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Save" HeaderText="Save">
<ItemTemplate>
<asp:ImageButton ID="btnSave" runat="server" ImageUrl="~/Images/Action_Save.png" Width="10px" Height="10px" CommandName="Save" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Delete" HeaderText="Delete">
<ItemTemplate>
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/Action_Delete.png" Width="10px" Height="10px" CommandName="Save" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
I need to hide the label lblAssgTo and make txtassgto visible in item command. I have the below code in item command.
protected void gridEconomist_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e != null)
{
e.Item.Edit = true;
GridEditableItem item = e.Item as GridDataItem;
item.Edit = true;
if (e.CommandName == "Edit")
{
TextBox txtAssgTo = (item.FindControl("txtAssgTo") as TextBox);
Label lblAssgTo = (item.FindControl("lblAssgTo") as Label);
Label lblorganization = (item.FindControl("lblorganization") as Label);
DropDownList ddlorganization = (item.FindControl("ddlorganization") as DropDownList);
lblAssgTo.Visible = false;
txtAssgTo.Visible = true;
ddlorganization.Visible = true;
lblorg.Visible = false;
}
}
}
When I debug I can see that the visible property is set to false in lblassg but it is not reflected in the UI. After item command the need data source event is fired. I'm not sure if thatis causing the issue.