ASP.NET-Repeater抓去特定控制項調整屬性(Repeater get control)
Repeater有時須抓某個index的值或者調整屬性就可以用到。
找到最後一筆調整enable屬性
RepeaterItem item = rp1.Items[rp1.Items.Count - 1];
DropDownList ddl_type = (DropDownList)item.FindControl("ddl_type");
ddl_type.Enabled = true;
TextBox type = (TextBox)item.FindControl("tbx_amount");
type.Enabled = true;
抓取每row的textbox跟dropdownlist的值
for (int i = 0; i < rp1.Items.Count; i++)
{
string a = ((TextBox)rp1.Items[i].FindControl("tbx_schedule")).Text;
string = ((DropDownList)rp1.Items[i].FindControl("ddl_type")).SelectedValue;
}
找到最後一筆調整enable屬性
RepeaterItem item = rp1.Items[rp1.Items.Count - 1];
DropDownList ddl_type = (DropDownList)item.FindControl("ddl_type");
ddl_type.Enabled = true;
TextBox type = (TextBox)item.FindControl("tbx_amount");
type.Enabled = true;
抓取每row的textbox跟dropdownlist的值
for (int i = 0; i < rp1.Items.Count; i++)
{
string a = ((TextBox)rp1.Items[i].FindControl("tbx_schedule")).Text;
string = ((DropDownList)rp1.Items[i].FindControl("ddl_type")).SelectedValue;
}
留言
張貼留言