Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
tnt_lu@hotmail.com #1
Parent/Child relations - Trying to access child control for save
I have a parent datagrid that has my customer information. For each
customer I have a child datagrid with all their part information. In
the child datagrid I have 4 radio buttons plus databound part
information. The radio buttons are not bound by data. They are
different selection types that will dictate how each part information
will be saved.
This is what I have currently:
C#.net - HTML
************************************************** ***************
<asp:datagrid id="DataGrid1" runat="server" Width="100%"
AutoGenerateColumns="False" CellSpacing="0"
CellPadding="0" ShowHeader="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<TABLE id="tblMain" cellSpacing="0" cellPadding="0" width="100%"
border="0">
<TR class="TableHead3">
<TD><B>End Customer:
<%# DataBinder.Eval(Container.DataItem, "ENDCUST") %>
</B>
</TR>
<TR>
<TD colSpan="2">
<TABLE id="tblDetail" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td align="right">
<asp:DataGrid id=DataGrid2 runat="server"
AutoGenerateColumns="False" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="1" GridLines="Vertical"
DataKeyField="CUSTOMERPARTID" OnItemDataBound="DataGrid2_ItemDataBound"
DataSource='<%# GetChildRelation(Container.DataItem,"relCustomerPa rt")
%>'>
<HeaderStyle Font-Bold="True"
CssClass="TableHead"></HeaderStyle>
<AlternatingItemStyle
CssClass="TblRow2"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" CssClass="TblAlt2"></ItemStyle>
<Columns>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:Label id="Label1"
runat="server">Unchanged</asp:Label> <A id="AllUnchanged"
class="Cursor" onclick="SetRadioDataGrid('rdoUnchanged',this.id); ">
<FONT color="yellow" size="1"><U>
<BR>
All</U></FONT></A>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton id="rdoUnchanged" runat="server"
GroupName="rbType" Checked="True"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:Label id="Label2"
runat="server">Revise</asp:Label><A id="AllRevised" class="Cursor"
onclick="SetRadioDataGrid('rdoRevised',this);"><FO NT color="yellow"
size="1"><U><BR>
All</U></FONT></A>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton id="rdoRevised" runat="server"
GroupName="rbType"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:Label id="Label3"
runat="server">Reference</asp:Label><A id="AllReferenced"
class="Cursor" onclick="SetRadioDataGrid('rdoReferenced',this);"> <FONT
color="yellow" size="1"><U><BR>
All</U></FONT></A>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton id="rdoReferenced" runat="server"
GroupName="rbType"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:Label id="Label4"
runat="server">Replace</asp:Label><A id="AllReplaced" class="Cursor"
onclick="SetRadioDataGrid('rdoReplaced',this);"><F ONT color="yellow"
size="1"><U><BR>
All</U></FONT></A>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton id="rdoReplaced" runat="server"
GroupName="rbType"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:Label id="Label5"
runat="server">Select</asp:Label><A id="AllSelect" class="Cursor"
onclick="SetRadioDataGrid('chkSelect',this);"><FON T color="yellow"
size="1"><U><BR>
All</U></FONT></A>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="chkSelect"
runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="CUSTOMERPARTID"
ReadOnly="True"></asp:BoundColumn>
<asp:BoundColumn DataField="ENDCUST_PART_NBR"
HeaderText="End Customer P/N">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center"
ForeColor="White"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="STATUS" HeaderText="Status">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center"
ForeColor="White"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Year" HeaderText="Model Year">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center"
ForeColor="White"></HeaderStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
</TABLE>
</TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
************************************************** ***************
aspx.cs
DataTable dtCustInfo = ds.Tables["tblCustomerInfo"];
DataTable dtCustParts = ds.Tables["tblCustomerParts"];
ds.Relations.Clear();
DataRelation relCustomerPart =
ds.Relations.Add("relCustomerPart",dtCustInfo.Colu mns["CUSTOMERPARTID"],dtCustParts.Columns["CUSTOMERPARTID"]);
DataView dvCustInfo = new
DataView(dtCustInfo,"","",DataViewRowState.Current Rows);
DataView dvCustParts;
this.DataGrid1.DataSource = dvCustInfo;
this.DataGrid1.DataBind();
************************************************** ***********
What I want to do is have a button on top of the form that will save
the child part information dependant on the selection of the radio
buttons. I can't seem to use the "FindControl" method for the page to
try to map a radio button control also since the Child Datagrid is in a
template, I can't seem to loop through the child datagrid either. Any
help would be great. I think the key is to be able to read my child
datagrid somehow.
Thanks in advance:
Todd
tnt_lu@hotmail.com Guest
-
Referencing a parent control from a child?
I have two UserControls I'd like to have talk to each other. One of them is contained within the other, in a parent/child relationship. The child... -
Child access to parent RemoteObject
I have an application with a RemoteObject that I want to share with child component (if that's the right term). Everything seems to work but I get... -
Why do property changes in child controls get copied to the parent control?
I have a control that contains a collection of another control. When I make a change in a property of one of the members of the collection (using... -
Notify child control of events in parent control
I have a parent control that has a imagebutton on it, with code to handle the click event. I also have various ascx controls that are loaded by the... -
Child user control accessing parent properties
We have a user control (Titlebar) that loads other user controls (children) into itself based on a property set in the HTML: <fss:Titlebar...



Reply With Quote

