![]() |
|
|
|
#1 |
|
hi everybody,
1) I am creating a form dynamically so all the controls like textbox, label, dropdownlist are created dynamically according to the values in the database. 2) I am also assigning values to this controls dynamically while page is loaded from the values in database. 3) I am also using masters page, content place holder Following is my aspx file.... <%@ Page Language="VB" MasterPageFile="~/TemplateAssets/Inside.master" AutoEventWireup="false" CodeFile="FormHandler.aspx.vb" Inherits="Forms_FormHandler" %> <asp:Content ID="FormContentFrame" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp <asp:HiddenField ID="HiddenFormID" runat="server" /> <asp:HiddenField ID="HiddenRespondentGUID" runat="server" /> <div align="right" style="padding-top:10px;"> <asp:CompareValidator ID="CompValDate" type="Date" Operator="DataTypeCheck" runat="server"></asp:CompareValidator> <asp:CompareValidator ID="CompValCurrency" type="Currency" Operator="DataTypeCheck" runat="server"></asp:CompareValidator> <asp:CompareValidator ID="CompValFloat" type="Double" Operator="DataTypeCheck" runat="server"></asp:CompareValidator> <asp:CustomValidator runat="server" ID="ValCheckBoxList" ClientValidationFunction="isChecked()"></asp:CustomValidator> <asp:Button ID="Val" runat="server" Text="Validate" OnClick="valcheckbox"/> <asp:TextBox ID="testing" runat="server" /> <asp:Button ID="SubmitButton" runat="server" Text="Submit" CssClass="SubmitButton" /> </div> </asp:Content> ----------------------------------------------------------------------- Following is my code behind file for creating dynamic controls and assigning values to it from database.. snap of code:- Case "CheckBoxList" 'LHS Column Dim r As New TableRow() Dim c As New TableCell() Dim Label As New Label Label.Text = record.Item("Label") c.Controls.Add(Label) c.VerticalAlign = VerticalAlign.Top r.Cells.Add(c) 'RHS Column c = New TableCell() Dim CheckboxList As New CheckBoxList Dim ResponseOptions As String = record.Item("ResponseOptions").ToString Dim ResponseOptionsArray As String() = Nothing ResponseOptionsArray = ResponseOptions.Split(",") CheckboxList.ID = record.Item("FieldGUID") Dim ResponseOption As String For Each ResponseOption In ResponseOptionsArray CheckboxList.Items.Add(ResponseOption) c.Controls.Add(CheckboxList) Next ResponseOption CheckboxList.SelectedIndex = 0 CheckboxList.ID = "checkboxlist" c.Controls.Add(l2) l2.Text = "Please Select One Of The CheckBox :- " 'Checkbox c.Controls.Add(CheckboxList) 3)--- And I am creating sub pro ( onclick the validation should fire ) Public Sub valcheckbox(ByVal sender As Object, ByVal e As System.EventArgs) Handles Val.Click l3.Text = "hello000000000000000000" l2.Text = " hello2000000000000000" testing.Text = "hello300000000000000000000" 'Dim userSelectionList As CheckBoxList = CType(FindControl("checkboxlist"), CheckBoxList) 'If userSelectionList.SelectedIndex = -1 Then ' l1.Text = "Please Select One Of The Option In CheckBoxList " 'End If 'Dim userSelectionList2 As DropDownList = CType(FindControl("dropdownlist"), DropDownList) 'If userSelectionList2.SelectedIndex = 0 Then ' l2.Text = "Please Select Any Item Other Then -Select- " 'End If End Sub ----->4) The main program is when i click on button it doesnt get fire it simply can't display label testing,l2,l3 just first line in the sub proce so i dont think its getting side ..? Also can any one please check my logic for validation dyamic is proper or not..? beacause all data and controls are created dynamic ..? Thanking you all.... Regards Mrugesh. mrugesh_dulera |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DropdownList in gridview | visj4u | Software | 0 | 04-27-2007 01:11 PM |