我在aspx / c#中创建了一个页面,它需要在下一页生成动态下拉列表的输入。下拉列表通过代码隐藏多次,具体取决于上一页中的输入。请建议我如何获取将在下一页生成的下拉列表的clientID。
//这是新页面的功能。如何获取ddlTimeOfDeath下拉列表的客户端ID
var tbl2 = new Table();
tbl2.ID = "tbl2";
tbl2.BorderWidth = 1;
tbl2.Attributes.Add("Width", "100%");
tbl2.Attributes.Add("CssClass", "tbl");
tbl2.Attributes.Add("rules", "all");
TableRow row1 = new TableRow();
TableCell cell00 = new TableCell();
TableCell cell11 = new TableCell();
TableCell cell22 = new TableCell();
TableCell cell33 = new TableCell();
TableCell cell44 = new TableCell();
TableCell cell55 = new TableCell();
TableCell cell66 = new TableCell();
cell00.Text = "Sl No."; cell00.Attributes.Add("Width", "2%");
cell00.Attributes.Add("class", "tblTDText"); cell00.Attributes.Add("align", "center"); row1.Cells.Add(cell00);
cell11.Text = "Activity Name"; cell11.Attributes.Add("Width", "8%");
cell11.Attributes.Add("Width", "20%"); cell11.Attributes.Add("class", "tblTDText"); row1.Cells.Add(cell11);
cell22.Text = "Name of woman"; cell22.Attributes.Add("Width", "15%");
cell22.Attributes.Add("class", "tblTDText"); cell22.Attributes.Add("align", "center"); row1.Cells.Add(cell22);
cell33.Text = "Address of woman"; cell33.Attributes.Add("Width", "15%");
cell33.Attributes.Add("class", "tblTDText"); cell33.Attributes.Add("align", "center"); row1.Cells.Add(cell33);
cell44.Text = "Place of Death"; cell44.Attributes.Add("Width", "10%");
cell44.Attributes.Add("class", "tblTDText"); cell44.Attributes.Add("align", "center"); row1.Cells.Add(cell44);
cell55.Text = "Time of Death"; cell55.Attributes.Add("Width", "10%");
cell55.Attributes.Add("class", "tblTDText"); cell55.Attributes.Add("align", "center"); row1.Cells.Add(cell55);
cell66.Text = "Cause of Death"; cell66.Attributes.Add("Width", "5%");
cell66.Attributes.Add("class", "tblTDText"); cell66.Attributes.Add("align", "center"); row1.Cells.Add(cell66);
tbl2.Rows.Add(row1);
for (int i = 0; i < actID.GetLength(0); i++)
{
string actId = actID[i, 0];
if (actId != null)
{
actId=actId.Trim();
if (actId == "12" || actId == "39" )
{
_objclstT389._i64T389001 = actId;
_objclstT389.fn_getRecordPr(_errMsg);
string actName = _objclstT389._strT389002;
int dcount = Convert.ToInt32(actID[i, 1]);
for (int j = 0; j < dcount; j++)
{
TableRow row = new TableRow();
TableCell cell0 = new TableCell();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();
//cell1.Text = actID[i, 0] + "/" + actName;
if (j == 0)
{
cell0.Text = Convert.ToString(i + 1);
cell0.RowSpan = dcount;
cell0.Attributes.Add("align", "center");
row.Cells.Add(cell0);
cell1.Text = actName;
cell1.Attributes.Add("valign", "top");
cell1.RowSpan = dcount;
row.Cells.Add(cell1);
}
cell2.Attributes.Add("valign", "top");
TextBox tb1 = new TextBox();
tb1.ID="txtNameOFWman"+j;
tb1.Attributes.Add("runat", "server");
cell2.Controls.Add(tb1);
cell2.Attributes.Add("align", "center");
row.Cells.Add(cell2);
cell3.Attributes.Add("valign", "top");
TextBox tb2 = new TextBox();
tb2.ID="txtAddrsOfWman"+j;
tb2.TextMode = TextBoxMode.MultiLine;
tb2.Attributes.Add("runat", "server");
cell3.Controls.Add(tb2);
cell3.Attributes.Add("align", "center");
row.Cells.Add(cell3);
cell4.Attributes.Add("valign", "top");
DropDownList ddl1 = new DropDownList();
ddl1.ID = "ddlPlaceOfDeath" + j;
ddl1.Attributes.Add("runat", "server");
ddl1.Items.Add(new ListItem("Select", "-1"));
ddl1.Items.Add(new ListItem("Hospital","1"));
ddl1.Items.Add(new ListItem("Home","2" ));
cell4.Controls.Add(ddl1);
cell4.Attributes.Add("align", "center");
row.Cells.Add(cell4);
cell5.Attributes.Add("valign", "top"); cell5.Attributes.Add("align", "middle");
DropDownList ddlTimeOfDeath = new DropDownList();
ddlTimeOfDeath.ID = "ddlTimeOfDeath" + j;
ddlTimeOfDeath.Attributes.Add("runat", "server");
ddlTimeOfDeath.Attributes.Add("onchange", "javascript:SelectedIndexChange('" + ddlTimeOfDeath.ClientID + "')");
ddlTimeOfDeath.Items.Add(new ListItem("Select", "-1"));
ddlTimeOfDeath.Items.Add(new ListItem("During Antenatal Period", "1"));
ddlTimeOfDeath.Items.Add(new ListItem("During delivery", "2"));
ddlTimeOfDeath.Items.Add(new ListItem("In postpartum report", "3"));
Literal ltlBrk1 = new Literal(); ltlBrk1.Text = "<br />";
TextBox txtDuration = new TextBox();
txtDuration.ID = "txtDuration" + j;
txtDuration.Attributes.Add("runat", "server");
txtDuration.Width = 40;
Label lblDuration = new Label();
lblDuration.ID = "lblDays" + j;
lblDuration.Attributes.Add("runat", "server");
lblDuration.Text = "Duration ";
TextBox txtNoOfDays = new TextBox();
txtNoOfDays.ID = "txtNoOfDays" + i;
txtNoOfDays.Attributes.Add("runat", "server");
txtNoOfDays.Width = 40;
Label lblNoOfDays = new Label();
lblNoOfDays.ID = "lblDays" + j;
lblNoOfDays.Attributes.Add("runat", "server");
lblNoOfDays.Text = "No. of days ";
cell5.Controls.Add(ddlTimeOfDeath);
cell5.Controls.Add(lblDuration);
cell5.Controls.Add(txtDuration); cell5.Controls.Add(ltlBrk1);
cell5.Controls.Add(lblNoOfDays);
cell5.Controls.Add(txtNoOfDays);
cell5.Attributes.Add("align", "center");
row.Cells.Add(cell5);
cell6.Attributes.Add("valign", "middle");
TextBox tb3 = new TextBox();
tb3.ID = "txtCauseOfDeath" + j;
tb3.Attributes.Add("runat", "server");
cell6.Controls.Add(tb3);
cell6.Attributes.Add("align", "center");
row.Cells.Add(cell6);
tbl2.Rows.Add(row);
}
}
}
}
phSecBActivity.Controls.Add(tbl2);