FindControl在各种场合的应用
来源:互联网 发布:ios 淘宝首页 编辑:程序博客网 时间:2024/06/05 03:05
Datalist
protected void btnToHtml_Click(object sender, EventArgs e)
{
for (int i = 0; i < gvArtice.Rows.Count; i++)
{
CheckBox cb = ((CheckBox)gvArtice.Rows[i].Cells[6].FindControl("CheckBox1"));
if (cb.Checked == true)
{
string htmlName = ((HyperLink)(gvArtice.Rows[i].Cells[5].FindControl("HyperLink1"))).Text;
string ddlName = ((DropDownList)FindControl("ddlChannel")).Text;
int id = Convert.ToInt32(gvArtice.Rows[i].Cells[0].Text);
string dir;
string tempName;
switch (ddlName)
{
case "1": dir = "htmlLw"; tempName = "tempLw.htm"; break;
case "2": dir = "htmlAl"; tempName = "tempAl.htm"; break;
case "3": dir = "htmlTz"; tempName = "tempTz.htm"; break;
case "4": dir = "htmlBz"; tempName = "tempBz.htm"; break;
case "5": dir = "htmlYb"; tempName = "tempYb.htm"; break;
case "6": dir = "htmlRj"; tempName = "tempRj.htm"; break;
default: dir = "htmlQt"; tempName = "tempQt.htm"; break;
}
try
{
createHtml.toHtml(htmlName, dir, tempName, "", "",id);
}
catch (Exception eToHtml)
{
Response.Write(eToHtml.Message);
}
}
}
//Response.Redirect("AuditArticle.aspx");
}
protected void dlComment_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label label = ((Label)e.Item.FindControl("Label2"));
if (label.Text == "0")
{
label.Text = "游客";
}
else
{
DB manager = new DB();
label.Text=manager.oneNumber("select username from bbs_users where uid=" + label.Text);
}
}
{
Label label = ((Label)e.Item.FindControl("Label2"));
if (label.Text == "0")
{
label.Text = "游客";
}
else
{
DB manager = new DB();
label.Text=manager.oneNumber("select username from bbs_users where uid=" + label.Text);
}
}
gridview
protected void gvArtice_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string fileName = ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).Text;
bool exists = File.Exists(Server.MapPath("~/htmllw/"+fileName));
Label lable = (Label)e.Row.Cells[5].FindControl("Label1");
if (exists)
{
lable.Text = "已生成";
((CheckBox)e.Row.Cells[6].FindControl("CheckBox1")).Checked = true;
}
else
{
lable.Text = "未生成";
lable.ForeColor = System.Drawing.Color.Red;
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string fileName = ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).Text;
bool exists = File.Exists(Server.MapPath("~/htmllw/"+fileName));
Label lable = (Label)e.Row.Cells[5].FindControl("Label1");
if (exists)
{
lable.Text = "已生成";
((CheckBox)e.Row.Cells[6].FindControl("CheckBox1")).Checked = true;
}
else
{
lable.Text = "未生成";
lable.ForeColor = System.Drawing.Color.Red;
}
}
protected void btnToHtml_Click(object sender, EventArgs e)
{
for (int i = 0; i < gvArtice.Rows.Count; i++)
{
CheckBox cb = ((CheckBox)gvArtice.Rows[i].Cells[6].FindControl("CheckBox1"));
if (cb.Checked == true)
{
string htmlName = ((HyperLink)(gvArtice.Rows[i].Cells[5].FindControl("HyperLink1"))).Text;
string ddlName = ((DropDownList)FindControl("ddlChannel")).Text;
int id = Convert.ToInt32(gvArtice.Rows[i].Cells[0].Text);
string dir;
string tempName;
switch (ddlName)
{
case "1": dir = "htmlLw"; tempName = "tempLw.htm"; break;
case "2": dir = "htmlAl"; tempName = "tempAl.htm"; break;
case "3": dir = "htmlTz"; tempName = "tempTz.htm"; break;
case "4": dir = "htmlBz"; tempName = "tempBz.htm"; break;
case "5": dir = "htmlYb"; tempName = "tempYb.htm"; break;
case "6": dir = "htmlRj"; tempName = "tempRj.htm"; break;
default: dir = "htmlQt"; tempName = "tempQt.htm"; break;
}
try
{
createHtml.toHtml(htmlName, dir, tempName, "", "",id);
}
catch (Exception eToHtml)
{
Response.Write(eToHtml.Message);
}
}
}
//Response.Redirect("AuditArticle.aspx");
}
- FindControl在各种场合的应用
- 各种排序应用场合
- RCP的应用场合
- xml的应用场合
- traits的应用场合
- Annotation的应用场合
- ServletContext的应用场合
- 各种Action的使用场合
- 各种场合的日期转换
- log4j在实际开发中应用场合的一些"潜规则"
- 设计模式的应用场合
- 扩展CalendarExtender的应用场合
- extern "C"的应用场合
- WeakReference 2 - 在什么场合下应用
- LUA脚本在游戏中的应用场合
- 各种分布及应用场合(建模对象)
- 各种分布及应用场合(建模对象)
- shell中各种括号()、(())、[]、[[]]、{},在什么场合下使用?
- ccna考试中的真题
- 基于.Net平台应用程序唯一运行实例实现(一)
- 高清时代走进奥运会
- 基于.Net平台应用程序唯一运行实例实现(二)
- 测试我的第一篇文章!
- FindControl在各种场合的应用
- 使用sqlplus连接数据库时报"ORA-12154:TNS:could not resolve the connect identifier specified"解决办法
- 征服 Ajax 应用程序的安全威胁
- 数据同步
- 在和大家一起分享下关于OSPF的有关知识
- [dp问题] pku 2295
- 我是新来的 CSDN
- Servlet及JSP中的多线程同步问题
- Global.asax.cs中的方法的含义