This is a migrated thread and some comments may be shown as answers.

How to Update a GridTemplateColumn

1 Answer 184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Jan 2012, 05:31 AM
Hi Sir:
I HAVE A RADGRID::
<telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" Width="99%"
  AutoGenerateColumns="False" DataSourceID="SqlDataSource2" EnableEmbeddedSkins="True"
  AutoGenerateEditColumn="True" AllowAutomaticUpdates="true"  CellSpacing="0" GridLines="None">

AND TWO IMPORTANT COLUMNS LIKE THESE:
<telerik:GridBoundColumn DataField="UJId" DataType="System.Int32" HeaderText="Upgrade ID"
ReadOnly="True" SortExpression="UJId" UniqueName="UJId" HeaderStyle-HorizontalAlign="center"
ItemStyle-HorizontalAlign="center">
</telerik:GridBoundColumn>

 <telerik:GridTemplateColumn HeaderText="Upgrade Status" SortExpression="UJStatus" UniqueName="UJStatus" DataField="UJStatus">
  <HeaderStyle Width="10%" />
  <ItemTemplate>
       <asp:Label runat="server" ID="lblUJStatus" Text='<%# Eval("UJStatus") %>'></asp:Label>
   </ItemTemplate>
   <EditItemTemplate>   
         <asp:DropDownList ID="UJStatusDropDownList" runat="server"  >
                  <asp:ListItem Text="Waiting" Value="Waiting" />
                  <asp:ListItem Text="Completed" Value="Completed" />
                   <asp:ListItem Text="Fail" Value="Fail" />
         </asp:DropDownList>
   </EditItemTemplate>
</telerik:GridTemplateColumn>

......
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AppSqlServer %>"
UpdateCommand = "UPDATE UJTable set UJStatus = @UJStatus where UJId = @UJId" 
SelectCommand="SELECT UJId, UJStatus From  UJView ...

......

I get two issues here:
one: when i clcik Edit , how can I set  UJStatusDropDownList select value to the value <%# Eval("UJStatus") %>
two: when i click Update after edit , It didn't update what I selected, but it only update null to UJStatus in the record

Many thanks

M Qiu


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Jan 2012, 05:57 AM
Hello,

The following online example illustarte the desired functionality.
Grid / Combo in Grid

Thanks,
Princy.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or