DataTable是否会重新传输另一个DataTable信息? [英] DataTable Retrives another DataTable Information?

查看:79
本文介绍了DataTable是否会重新传输另一个DataTable信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的实时应用程序中有异常.DataTable重新传输另一个DataTable信息..



  if (HttpContext.Current.User!=  null 
{

if (会话[ 用户名]!= null
{
string pageName = Page.Page.AppRelativeVirtualPath.Substring(Page。 Page.AppRelativeVirtualPath.LastIndexOf(' /')+ 1 );
DataTable dtFeatures2 = new DataTable();
dtFeatures2.Clear();
objMatermenuPL.usertype = Session [ UserType]。ToString();
dtFeatures2 = objMastermenuBAL.GetMastermenu(objMatermenuPL);

DataView dt = new DataView(dtFeatures2);
dt.Sort = fld_feature ASC;

if (dtFeatures2!= null
{
foreach (控制控件 leftpanel.Controls)
{
类型ty = control.GetType();
if (ty.Name.ToUpper()== HTMLANCHOR
{
int i = dt.Find(control.ID.Substring( 3 ));
if (i < 0 && control.ID.Contains( lnk))
control .Visible = false ;
if (control.ID.Contains( lnk)&& control.ID.Substring( 3 )+ .aspx == pageName)
{
HtmlAnchor a =(HtmlAnchor)control;
a.Attributes.Add( class active);
}
}
}
}


}
}
else
{
Response.Redirect( 〜/ Login.aspx );
}



我们使用的代码所有大部分母版页...如果异常提升,则直接来源

这一行..

 dtFeatures2 = objMastermenuBAL.GetMastermenu(objMatermenuPL); 



消息:找不到列fld_feature。



dtFeatures2填充之前打开页面数据表信息...



此异常消失了一些......它工作正常100%....有时只显示这些异常......

解决方案

试试这样



  if (dtFeatures2!=  null 
{
// 下面的条件内的代码......
DataView dt = new DataView(dtFeatures2) ;
dt.Sort = fld_feature ASC;


I Have an Exception in my Live Application..DataTable Retrives another DataTable information..

if (HttpContext.Current.User != null)
           {

               if (Session["username"] != null)
               {
                   string pageName = Page.Page.AppRelativeVirtualPath.Substring(Page.Page.AppRelativeVirtualPath.LastIndexOf('/') + 1);
                   DataTable dtFeatures2 = new DataTable();
                   dtFeatures2.Clear();
                   objMatermenuPL.usertype = Session["UserType"].ToString();
                   dtFeatures2 = objMastermenuBAL.GetMastermenu(objMatermenuPL);

                   DataView dt = new DataView(dtFeatures2);
                   dt.Sort = "fld_feature ASC";

                   if (dtFeatures2 != null)
                   {
                       foreach (Control control in leftpanel.Controls)
                       {
                           Type ty = control.GetType();
                           if (ty.Name.ToUpper() == "HTMLANCHOR")
                           {
                               int i = dt.Find(control.ID.Substring(3));
                               if (i < 0 && control.ID.Contains("lnk"))
                                   control.Visible = false;
                               if (control.ID.Contains("lnk") && control.ID.Substring(3) + ".aspx" == pageName)
                               {
                                   HtmlAnchor a = (HtmlAnchor)control;
                                   a.Attributes.Add("class", "active");
                               }
                           }
                       }
                   }


               }
           }
           else
           {
               Response.Redirect("~/Login.aspx");
           }


This code we use All most all master pages...If an exception Raise,then it comes directly
this line..

dtFeatures2 = objMastermenuBAL.GetMastermenu(objMatermenuPL);


Message like : Cannot find column fld_feature.

"dtFeatures2" is Filled With Before Opened Page DataTable Information...

This exception gone after some..It's Working Fine 100%....Some times only shows these exception...

解决方案

Try like this

if (dtFeatures2 != null)
                   {
// below codes inside the condition...
                       DataView dt = new DataView(dtFeatures2);  
                       dt.Sort = "fld_feature ASC";


这篇关于DataTable是否会重新传输另一个DataTable信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆