Re: "Dynamic" form -- how to?
- From: "Bart Van Hemelen" <bartvanhemelen@xxxxxxxxx>
- Date: 11 Mar 2006 06:31:02 -0800
Brett Wiltshire wrote:
A DataGrid seems like the right choice to me.
You didn't mention *why* you're stuck ... which is a something of an
impediment to further advice ... :-)
Yeah, I was just wondering if anyone had ever done such a thing and
what their experiences were.
However, I've now run into several problems. Here's how I'm now doing
the datagrid:
<asp:datagrid id="dgMemberList" runat="server"
AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateColumn HeaderText="Last Name">
<ItemTemplate>
<asp:TextBox runat="server" id="txtLastName" Text='' />
<asp:RequiredFieldValidator id="rfLastName"
ControlToValidate="txtLastName" Text="The last name field is required!"
runat="server" Display="None" EnableClientScript="false" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Gender">
<ItemTemplate>
<asp:DropDownList id="ddGender"
runat="server"></asp:DropDownList>
<asp:RequiredFieldValidator id="rfGender"
ControlToValidate="ddGender" Text="The Gender field is required!"
runat="server" Display="None" EnableClientScript="false" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
<asp:Button id="cmdSubmit" Text=" Continue " runat="server" />
<asp:ValidationSummary id="lblSummary" runat="server"
ShowMessageBox="false" HeaderText="Errors are as
follows:"></asp:ValidationSummary>
1. I want to populate ddGender with data from the database (*), however
when I tried to it didn't work:
ddGender.Items.Insert(0, new ListItem( "Male" , "1" ) );
ddGender.Items.Insert(0, new ListItem( "Female" , "2" ) );
Result: " System.NullReferenceException: Object reference not set to an
instance of an object." I'm guessing that I need to loop through the
Items collection of the DataGrid and access each filed that way?
(*) Yes I know that this is silly when it comes to gender, but there
are other fields like nationality that do come from the database, and
anyway I do need to fill ddGender with data.
2. When I click the submit button, I do get to see the title of the
lblSummary, but no actual errors. I'm guessing that a similar problem
is happening here: the RequiredFieldValidator cannot find the control
it is supposed to check?
Reason I'm not debugging with VisualStudio: I'm at home and I don't
have VS installed here.
--
BVH
.
- Follow-Ups:
- Re: "Dynamic" form -- how to?
- From: Brett Wiltshire
- Re: "Dynamic" form -- how to?
- References:
- "Dynamic" form -- how to?
- From: Bart Van Hemelen
- Re: "Dynamic" form -- how to?
- From: Brett Wiltshire
- "Dynamic" form -- how to?
- Prev by Date: Re: it's really important thing to solve
- Next by Date: RE: Tell user page is "working" - not changing the page
- Previous by thread: Re: "Dynamic" form -- how to?
- Next by thread: Re: "Dynamic" form -- how to?
- Index(es):