L
Linus
Hi,
I have a datagrid nested inside another datagrid, the
edit/update/cancel command works fine on the outter datagrid but I'm
having problems with the inner one. There are 2 problems and here's
the code for my inner datagrid's EditCommand:
public void dgInner_EditCommand(object sender,
DataGridCommandEventArgs e)
{
dgInner = sender as DataGrid;
dgInner.EditItemIndex = e.Item.ItemIndex;
dgInner.DataSource = GetInnerGridData();
dgInner.DataBind();
}
If I rebind the data like above, the grid doesn't show any data
at all. And if I comment out the last two lines; i.e., without
rebinding, the datagrid remains the same until I click on the Edit
button the 2nd time then the Update and Cancel button shows and the
grid goes into the edit mode.
Here's my ASP code, I'd appreciate it if anyone could help.
Thanks.
<aspataGrid AutoGenerateColumns="false"
BorderColor="#cccccc"
BorderStyle="None"
BorderWidth="1"
CellPadding="3"
DataSource='<%# GetPrescriptions(DataBinder.Eval(Container.DataItem,
"phar_order_no")) %>'
HeaderStyle-BackColor = "#4169E1"
HeaderStyle-Font-Name = "verdana"
HeaderStyle-Font-Size = "10px"
HeaderStyle-Font-Bold = "True"
HeaderStyle-ForeColor = "#FFFFFF"
id="dgInner"
OnEditCommand="dgInner_EditCommand"
OnCancelCommand="dgInner_CancelCommand"
runat="server"
Width="80%">
<AlternatingItemStyle Font-Size="XX-Small" Font-Names="Verdana"
ForeColor="DarkBlue" BackColor="AliceBlue"></AlternatingItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Verdana" Height="20px"
ForeColor="DarkBlue" BackColor="White"></ItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="Column 1">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "c1") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Completed">
<ItemTemplate>
<asp:CheckBox ID="chkLineCompleted" Enabled="False" Checked='<%#
DataBinder.Eval(Container.DataItem, "completed") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="edit_chkLineCompleted" Enabled="True" Checked='<%#
DataBinder.Eval(Container.DataItem, "completed") %>' Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Action">
<itemtemplate>
<asp:imagebutton runat="server" CommandName="Edit"
ImageUrl="Images/icon_edit.gif" ID="Imagebutton1" AlternateText="Edit"
Height="12" Width="12" /> <br>
</itemtemplate>
<edititemtemplate>
<asp:imagebutton runat="server" CommandName="Update"
ImageUrl="Images/icon_save.gif" ID="Imagebutton2"
AlternateText="Update" Height="12" Width="12" />
<asp:imagebutton runat="server" CommandName="Cancel"
ImageUrl="Images/icon_cancel.gif" ID="Imagebutton3"
AlternateText="Cancel" Height="12" Width="12" /> <br>
</edititemtemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
I have a datagrid nested inside another datagrid, the
edit/update/cancel command works fine on the outter datagrid but I'm
having problems with the inner one. There are 2 problems and here's
the code for my inner datagrid's EditCommand:
public void dgInner_EditCommand(object sender,
DataGridCommandEventArgs e)
{
dgInner = sender as DataGrid;
dgInner.EditItemIndex = e.Item.ItemIndex;
dgInner.DataSource = GetInnerGridData();
dgInner.DataBind();
}
If I rebind the data like above, the grid doesn't show any data
at all. And if I comment out the last two lines; i.e., without
rebinding, the datagrid remains the same until I click on the Edit
button the 2nd time then the Update and Cancel button shows and the
grid goes into the edit mode.
Here's my ASP code, I'd appreciate it if anyone could help.
Thanks.
<aspataGrid AutoGenerateColumns="false"
BorderColor="#cccccc"
BorderStyle="None"
BorderWidth="1"
CellPadding="3"
DataSource='<%# GetPrescriptions(DataBinder.Eval(Container.DataItem,
"phar_order_no")) %>'
HeaderStyle-BackColor = "#4169E1"
HeaderStyle-Font-Name = "verdana"
HeaderStyle-Font-Size = "10px"
HeaderStyle-Font-Bold = "True"
HeaderStyle-ForeColor = "#FFFFFF"
id="dgInner"
OnEditCommand="dgInner_EditCommand"
OnCancelCommand="dgInner_CancelCommand"
runat="server"
Width="80%">
<AlternatingItemStyle Font-Size="XX-Small" Font-Names="Verdana"
ForeColor="DarkBlue" BackColor="AliceBlue"></AlternatingItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Verdana" Height="20px"
ForeColor="DarkBlue" BackColor="White"></ItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="Column 1">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "c1") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Completed">
<ItemTemplate>
<asp:CheckBox ID="chkLineCompleted" Enabled="False" Checked='<%#
DataBinder.Eval(Container.DataItem, "completed") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="edit_chkLineCompleted" Enabled="True" Checked='<%#
DataBinder.Eval(Container.DataItem, "completed") %>' Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Action">
<itemtemplate>
<asp:imagebutton runat="server" CommandName="Edit"
ImageUrl="Images/icon_edit.gif" ID="Imagebutton1" AlternateText="Edit"
Height="12" Width="12" /> <br>
</itemtemplate>
<edititemtemplate>
<asp:imagebutton runat="server" CommandName="Update"
ImageUrl="Images/icon_save.gif" ID="Imagebutton2"
AlternateText="Update" Height="12" Width="12" />
<asp:imagebutton runat="server" CommandName="Cancel"
ImageUrl="Images/icon_cancel.gif" ID="Imagebutton3"
AlternateText="Cancel" Height="12" Width="12" /> <br>
</edititemtemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>