EditCommand on a Nested DataGrid...

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.

<asp:DataGrid 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" />&nbsp;<br>
</itemtemplate>
<edititemtemplate>
<asp:imagebutton runat="server" CommandName="Update"
ImageUrl="Images/icon_save.gif" ID="Imagebutton2"
AlternateText="Update" Height="12" Width="12" />&nbsp;&nbsp;
<asp:imagebutton runat="server" CommandName="Cancel"
ImageUrl="Images/icon_cancel.gif" ID="Imagebutton3"
AlternateText="Cancel" Height="12" Width="12" />&nbsp;<br>
</edititemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top