I created a user control in Asp.Net which I populate with <asp:Table id = "...." />
this table has columns that contain dropdownlists, textfields and other web controls...
In the code behind I am not able to access these web controls, is there a way I can access them.......or I shouldn't be doing that in the code behind of the user control???
here is my ascx code markup:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MarriageControl.ascx.cs" %>
<%@ Register assembly="BasicFrame.WebControls.BasicDatePicker" namespace="BasicFrame.WebControls" tagprefix="BDP" %>
<asp:TextBox ID = test runat = "server" />
<asp:Table ID = "marriageInfoTable" runat = "server" Caption="معلومات الزواج"
CellPadding="2" CellSpacing="2" Width="979px" Height="164px">
<asp:TableRow runat="server">
<asp:TableHeaderCell runat = "server" Text = " " />
<asp:TableHeaderCell runat = "server" ID = "husbandHeader" Text = "الزوج" HorizontalAlign = "Right" />
<asp:TableHeaderCell runat = "server" ID = "wifeHeader" Text = "الزوجة" HorizontalAlign = "Right" />
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat = "server" Text ="الاسم الرباعي" />
<asp:TableCell runat = "server">
<asp:TextBox runat ="server" ID = "fullNameHusbandTextBox" Height = "30px" Width = "250px" Font-Bold = "true" Font-Size = "20px"/>
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:TextBox runat ="server" ID = "fullNameWifeTextBox" Height = "30px" Width = "250px" Font-Bold = "true" Font-Size = "20px"/>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell ID="dateOfBirthCell" runat = "server" Text ="تاريخ الميلاد" />
<asp:TableCell runat = "server">
<BDP:BasicDatePicker ID="dateOfBirth_husband" runat="server" DateFormat = "yyyy/MM/dd" />
</asp:TableCell>
<asp:TableCell ID="TableCell3" runat = "server">
<BDP:BasicDatePicker ID="dateOfBirth_wife" runat="server" DateFormat = "yyyy/MM/dd"/>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat = "server" Text = "مكان الإقامة" />
<asp:TableCell runat = "server">
<asp:DropDownList runat = "server" ID = "residenceHusbandPickList" />
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:DropDownList runat = "server" ID = "residenceWifePickList" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat = "server" Text = "اسم و شهرة الأب والأم"/>
<asp:TableCell runat = "server">
<asp:Table runat = "server" ID = "nameOfFatherMother_Husband">
<asp:TableRow runat = "server">
<asp:TableCell runat = "server">
<asp:Label runat = "server" Text = "اسم الأب الرباعي" />
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:TextBox runat = "server" id = "nameOfFather_Husband" Width = "200px" Font-Bold = "true" Font-Size = "20px" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat = "server">
<asp:TableCell runat = "server">
<asp:Label ID="Label1" runat = "server" Text = "اسم الأم الرباعي" />
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:TextBox runat = "server" id = "nameOfMother_Husband" Width = "200px" Font-Bold = "true" Font-Size = "20px" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:Table runat = "server" ID = "Table1">
<asp:TableRow ID="TableRow1" runat = "server">
<asp:TableCell ID="TableCell1" runat = "server">
<asp:Label ID="Label2" runat = "server" Text = "اسم الأب الرباعي" />
</asp:TableCell>
<asp:TableCell ID="TableCell2" runat = "server">
<asp:TextBox runat = "server" id = "nameOfFather_Wife" Width = "200px" Font-Bold = "true" Font-Size = "20px" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow2" runat = "server">
<asp:TableCell ID="TableCell4" runat = "server">
<asp:Label ID="Label3" runat = "server" Text = "اسم الأم الرباعي" />
</asp:TableCell>
<asp:TableCell ID="TableCell5" runat = "server">
<asp:TextBox runat = "server" id = "nameOfMother_Wife" Width = "200px" Font-Bold = "true" Font-Size = "20px" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat = "server">
<asp:Label runat = "server" Text = "مكان إقامة الأب والأم"></asp:Label>
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:Table runat = "server">
<asp:TableRow runat = "server">
<asp:TableCell runat = "server">
<asp:Label runat="server" Text = "مكان سكن الأب" ></asp:Label>
</asp:TableCell>
<asp:TableCell runat = "server">
<asp:DropDownList ID = "residenceOfFather_Husband" runat = "server"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat = "server">
<asp:TableCell ID="TableCell6" runat = "server">
<asp:Label ID="Label4" runat="server" Text = "مكان سكن الأم" ></asp:Label>
</asp:TableCell>
<asp:TableCell ID="TableCell7" runat = "server">
<asp:DropDownList ID = "residenceOfMother_Husband" runat = "server"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
<asp:TableCell ID="TableCell8" runat = "server">
<asp:Table ID="Table2" runat = "server">
<asp:TableRow ID="TableRow3" runat = "server">
<asp:TableCell ID="TableCell9" runat = "server">
<asp:Label ID="Label5" runat="server" Text = "مكان سكن الأب" ></asp:Label>
</asp:TableCell>
<asp:TableCell ID="TableCell10" runat = "server">
<asp:DropDownList ID = "residenceOfFather_Wife" runat = "server"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow4" runat = "server">
<asp:TableCell ID="TableCell11" runat = "server">
<asp:Label ID="Label6" runat="server" Text = "مكان سكن الأم" ></asp:Label>
</asp:TableCell>
<asp:TableCell ID="TableCell12" runat = "server">
<asp:DropDownList ID = "residenceOfMother_Wife" runat = "server"></asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat = "server">
<asp:Label runat = "server" ID = "nameOfWitnesses" Text = "أسماء الشهود" />
</asp:TableCell>
<asp:TableCell ID="tblCellWitnesses_Husband" runat = "server">
<asp:Table runat = "server">
<asp:TableRow runat = "server">
<asp:TableCell runat = "server">
<asp:TextBox ID = "witnessName" runat = "server" Width = "250px" />
<asp:Button ID = "addWitness" runat = "server" Text = "أضف شاهد" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:TableCell>
<asp:TableCell ID="tblCellWitnesses_Wife" runat = "server">
<asp:TextBox ID = "TextBox1" runat = "server" Width = "250px" />
<asp:Button ID = "addWitness2" runat = "server" Text = "أضف شاهد" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
in my code behind (ascx.cs) i am trying to fill the dropdown with data ... I just can't type the id of anything I have and use it.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//appropriate connection start
dataBaseConnection = new SqlConnection();
dataBaseConnection.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\ChurchApp\ChurchApplication\App_Data\Database.mdf;Integrated Security=True;User Instance=True";
dataAdapter = new SqlDataAdapter("SELECT * FROM Country");
ds = new DataSet();
dataAdapter.Fill(ds, "CountryTable");
}