//我是用的动态的方法,绑定一个数据源数据。protected void Page_Load(object sender, EventArgs e) {/*初始化表记录*/BSelectPlayFileInfBLL " />

关于动态生成 实现新页面 的问题,求解

来源:互联网  时间:2016/6/28 14:17:18

关于网友提出的“ 关于动态生成 实现新页面 的问题,求解”问题疑问,本网通过在网上对“ 关于动态生成 实现新页面 的问题,求解”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 关于动态生成 实现新页面 的问题,求解
描述:


   
   //我是用的动态的方法,绑定一个数据源数据。

 protected void Page_Load(object sender, EventArgs e)
{
      /*初始化表记录*/
            BSelectPlayFileInfBLL sebll=new BSelectPlayFileInfBLL();
            string time =DropDownList1.SelectedValue;
            string type =DropDownList2.SelectedValue;
          /*  switch ()             {                 case "Vedio":
            }*/
            DataTable dt=sebll.SelectPlayFileInfBLL(time ,type);             if (dt == null)
            {             }             else
            {                 InitTable2(dt);             } }    private void InitTable2(DataTable dt)         {/*这里*/<>             int counts=dt.Rows.Count;             int index=(int)ViewState["PageIndex"];
            int pagesize=(int)ViewState["PageSize"];<>             int j = 0;             string style ="fontsize:12px;background:#FFCC99;";                          for (int i = index*pagesize ; i < dt.Rows.Count&&i<(index+1)*pagesize ; i++,j++)             {                 string userdearname=dt.Rows[i]["User_DearName"].ToString();                 string filename=dt.Rows[i]["File_Name_"].ToString();                 string filepath=dt.Rows[i]["File_Path"].ToString();                 string startting=dt.Rows[i]["Startting"].ToString();                 string ended=dt.Rows[i]["Ended"].ToString();                 string filesize=dt.Rows[i]["File_Size"].ToString();                 string filetype ="出错" ;                 switch (dt.Rows[i]["File_Type"].ToString())                 {                     case "1":                         filetype = "视频";                         break;                     case "2":                         filetype = "图片";                         break;                     case "3":                         filetype = "Logo标志";                         break;                     case "4":                         filetype = "缓冲图片";                         break;                     case "5":                         filetype = "升级文件";                         break;                     case "6":                         filetype = "文本文件";                         break;                                          }                                  TableRow tr = new TableRow();                 tr.Cells.Add(AddTableTextCell(style ,userdearname));                 tr.Cells.Add(AddTableTextCell(style ,filename));                 tr.Cells.Add(AddTableTextCell(style ,startting));                 tr.Cells.Add(AddTableTextCell(style ,ended));                 tr.Cells.Add(AddTableTextCell(style ,filetype));                 tr.Cells.Add(AddTableTextCell(style, filesize));                 tr.Cells.Add(AddTableControlCell(style ,"预览" ,"LinkButton" ,"lb"+i.ToString()) );                 tr.Cells.Add(AddTableControlCell(style ,"" ,"CheckBox" ,"cb"+i.ToString() ));                 TableCell td=AddTableTextCell("" ,filepath);  //添加一个隐藏列,用于存放filepath                 td.Visible = false;                 tr.Cells.Add(td);                 
                Table2.Rows.Add(tr);             }             if (counts > pagesize)             {                 if (counts % pagesize == 0)                 {                     ViewState["Pages"] = counts / pagesize;                 }                 else                 {                     ViewState["Pages"] = counts / pagesize + 1;                 }
                SetPageVisible(true, index, (int)ViewState["Pages"], counts);             }
            else                 SetPageVisible(false,0, 0, 0);         }       /*添加文本列*/         private TableCell AddTableTextCell(string style, string text)         {             TableCell td = new TableCell();             td.Attributes.Add("style", style);             td.Text = text;             td.Width = 100;             return td;         }         /*添加控件列*/         private TableCell AddTableControlCell(string style, string text, string controltype, string controlid)         {             TableCell td = new TableCell();             td.Width = 100;             td.Attributes.Add("style", style);             switch (controltype.ToLower())             {                 case "checkbox":                     {                         CheckBox cb = new CheckBox();                         cb.ID = controlid;                         if (controlid.Substring(2) == "A")  /*如果需要对每个checkbox都要求有触发事件,就不必判断*/                         {                             cb.AutoPostBack = true;                             cb.CheckedChanged += new EventHandler(cb_CheckedChanged);
                        }
                        td.Controls.Add(cb);                     }                     break;                 case "linkbutton":                     {                         LinkButton lb = new LinkButton();                         lb.ID = controlid;                         lb.Text = text;
                        lb.Click += new EventHandler(lb_Click);                         td.Controls.Add(lb);                     }
                    break;             }             return td;         }    /*预览*/         protected void lb_Click(object sender ,EventArgs e)         {
            LinkButton lb = sender as LinkButton;             int pagess=(int)ViewState["PageIndex"] * (int)ViewState["PageSize"];             string type=null;
            int index=Convert.ToInt16(lb.ID.Substring(2))-pagess;
            Session["File_Path"] = (Table2.Rows[index].Cells[8]).Text;
            type = (Table2.Rows[index].Cells[4]).Text ;             string url = "SeeFileForCheckWebUI.aspx?"+type;            // Respose.Write( "  window.open( ' "+   url + " ');  "); //这里,确实不知道该怎么添加一个弹出的新页面链接,求解惑                      }


解决方案1:

什么意思?动态生成后要刷新还是不刷新吗?

上一篇求高手解决一下word转html的问题
下一篇devexpress net 中的ASPXGridView中的CustomButton如何利用Popupcontrol弹出一个窗体?
明星图片
相关文章
《 关于动态生成 实现新页面 的问题,求解》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)