you have to do it in ItemDataBound event handler, but here is a simpler solution:<asp:TemplateColumn>
 <ItemTemplate> <asp:TextBox id="txt_cj" Runat="server" text='' Visible='<%# SomeCondition%>'></asp:TextBox>  
          <asp:DropDownList id="ddl" Runat="server" Visible='<%# !SomeCondition %>'></asp:DropDownList>  
 </ItemTemplate>
</asp:TemplateColumn>replace "SomeCondition" with some expression which might be of the format of
(bool)DataBinder.Eval(Container.DataItem,"SomeColumn")