Bound Template Column in DataGrid
I have a datagrid that contains a dropdown list in a template columun.
Here's the HTML:
<asp:TemplateColumn HeaderText="Result">
<ItemTemplate>
<asp:DropDownList id="lstResultValue" runat="server">
<asp:ListItem Value="Todo">Todo</asp:ListItem>
<asp:ListItem Value="Pass">Pass</asp:ListItem>
<asp:ListItem Value="Fail">Fail</asp:ListItem>
<asp:ListItem Value="Unnecessary">Unnecessary</asp:ListItem>
<asp:ListItem Value="Blocked">Blocked</asp:ListItem>
<asp:ListItem Value="In Progress">In Progress</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
It all works the way it should, changes get posted back to the database, etc. However, when the page loads, what shows in each cell in this column is the top item in the dropdown. What I want to show is the value for this field in the database, sort of a bound template column. It seems to me that that should be the default, but I can't find any way to do that.
Am I missing something obvious, or am I out of luck? A pointer to a C# code sample would be most helpful.
Thanks much,
Dennis
|