470,619 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

EditCommand on a Nested DataGrid...

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.DataIte m,
"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>
Nov 18 '05 #1
0 1114

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by bmoman | last post: by
4 posts views Thread by Richard Roche | last post: by
reply views Thread by Chad Folden | last post: by
1 post views Thread by bill yeager | last post: by
1 post views Thread by jacobryce | last post: by
1 post views Thread by benoit | last post: by
1 post views Thread by Joe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.