Parent/Child relations - Trying to access child control for save

T

tnt_lu

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,"relCustomerPart")
%>'>
<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>&nbsp; <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);"><FONT 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);"><FONT 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);"><FONT 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.Columns["CUSTOMERPARTID"],dtCustParts.Columns["CUSTOMERPARTID"]);

DataView dvCustInfo = new
DataView(dtCustInfo,"","",DataViewRowState.CurrentRows);
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
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top