T
Tom Vukovich
Hi All,
I am having a bit of a problem retrieving the datagrid object to retrieve values the uses enters.
When i code the Columns in the HTML page everything works fine.
<asp:datagrid id="dgDispatch" Width="70%" Font-Size="x-small" runat="server">
<Columns>
<asp:BoundColumn HeaderText = "Hour Ending" DataField="Hour Ending" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Previous" DataField="Previous" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "MW Request" DataField="MW Request" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Hour Ending" DataField="Hour Ending1" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Previous" DataField="Previous1" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "MW Request" DataField="MW Request1" ></asp:BoundColumn>
</Columns>
But I want the flexibility of building the columns in code. When the user click on the Edit button a template column is created and a usercontrol is assigned the value of the column to be edited.
'Dynamic column
Dim col5 As New TemplateColumn
col5.ItemTemplate = Page.LoadTemplate("ItemEdit1.ascx")
col5.HeaderStyle.Width = Unit.Percentage(20)
col5.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col5.HeaderText = "Requested MW"
col5.ItemStyle.HorizontalAlign = HorizontalAlign.Center
dgDispatch.Columns.Add(col5)
the itemedit1.ascx code,
<table>
<tr>
<td>
<asp:RadioButtonList AutoPostBack="false" Font-Size=x-small RepeatDirection="Horizontal" ID="rbEdit" Runat="server">
<asp:ListItem Selected="true" Value="0">Max</asp:ListItem>
<asp:ListItem Selected="false" Value="1">Min</asp:ListItem>
<asp:ListItem Selected="false" Value="2">Other</asp:ListItem>
</asp:RadioButtonList>
</td>
<td align = right>
<asp:TextBox BackColor="#ffffcc" Font-Size=x-small Width = 60 ID=txtMW1 Runat=server Text= '<%# DataBinder.Eval(Ctype(Container,DataGridItem).dataitem, "MW Request1") %>'>
</asp:TextBox>
</td>
</tr>
</table>
When I generate the table contents in code, the datagrid object is not available following a post back. However when i place the datagrid templates in the page HTML all works fine.
There must be some little thing i am doing wrong. I hope someone can help.
tv
(e-mail address removed)
I am having a bit of a problem retrieving the datagrid object to retrieve values the uses enters.
When i code the Columns in the HTML page everything works fine.
<asp:datagrid id="dgDispatch" Width="70%" Font-Size="x-small" runat="server">
<Columns>
<asp:BoundColumn HeaderText = "Hour Ending" DataField="Hour Ending" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Previous" DataField="Previous" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "MW Request" DataField="MW Request" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Hour Ending" DataField="Hour Ending1" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "Previous" DataField="Previous1" ></asp:BoundColumn>
<asp:BoundColumn HeaderText = "MW Request" DataField="MW Request1" ></asp:BoundColumn>
</Columns>
But I want the flexibility of building the columns in code. When the user click on the Edit button a template column is created and a usercontrol is assigned the value of the column to be edited.
'Dynamic column
Dim col5 As New TemplateColumn
col5.ItemTemplate = Page.LoadTemplate("ItemEdit1.ascx")
col5.HeaderStyle.Width = Unit.Percentage(20)
col5.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
col5.HeaderText = "Requested MW"
col5.ItemStyle.HorizontalAlign = HorizontalAlign.Center
dgDispatch.Columns.Add(col5)
the itemedit1.ascx code,
<table>
<tr>
<td>
<asp:RadioButtonList AutoPostBack="false" Font-Size=x-small RepeatDirection="Horizontal" ID="rbEdit" Runat="server">
<asp:ListItem Selected="true" Value="0">Max</asp:ListItem>
<asp:ListItem Selected="false" Value="1">Min</asp:ListItem>
<asp:ListItem Selected="false" Value="2">Other</asp:ListItem>
</asp:RadioButtonList>
</td>
<td align = right>
<asp:TextBox BackColor="#ffffcc" Font-Size=x-small Width = 60 ID=txtMW1 Runat=server Text= '<%# DataBinder.Eval(Ctype(Container,DataGridItem).dataitem, "MW Request1") %>'>
</asp:TextBox>
</td>
</tr>
</table>
When I generate the table contents in code, the datagrid object is not available following a post back. However when i place the datagrid templates in the page HTML all works fine.
There must be some little thing i am doing wrong. I hope someone can help.
tv
(e-mail address removed)