DataBinding:“System.Data.DataRowView”不包含名为“RealName”的属性。

ssswww5178 2011-10-19 12:45:09
错误提示:DataBinding:“System.Data.DataRowView”不包含名为“RealName”的属性

行 184: 昵称</HeaderTemplate>
行 185: <ItemTemplate>
行 186: <%# Eval("RealName")%>
行 187: </ItemTemplate>
行 188: </asp:TemplateField>

代码:
<%@ control language="C#" autoeventwireup="true"inherits="Admin_ChartType_2, aaAlly.aU_deploy" %>
<%@ Register Src="DateUser.ascx" TagName="DateUser" TagPrefix="uc1" %>


(aaAlly.aU_deploy这个文件是被封存为DLL了,编辑不了)

<Columns>
<asp:TemplateField>
<HeaderTemplate>
代理商账号</HeaderTemplate>
<ItemTemplate>
<a href='../Chart/AgentInfo.aspx?aid=<%#Eval("AGENTID") %>' title="点击查看该代理账务信息">
<%# Eval("AGENTNAME")%>
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
昵称</HeaderTemplate>
<ItemTemplate>
<%# Eval("RealName")%> 《-----(这个RealName在数据库里面是有的)
</ItemTemplate>
</asp:TemplateField>

高手们,有没有办法让程序读这个RealName里面的数据而不出错?
...全文
298 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssswww5178 2011-10-21
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 net_lover 的回复:]
方法
首先去 http://jquery.com/下载jquery-1.6.4.min.js

在页面中加入
<script src="jquery-1.6.4.min.js" type="text/javascript"></script>


<ItemTemplate>
<div id='d<%#Eval("AGENTID")%>'></div>
<script>
$('……
[/Quote]
非常非常感谢这位朋友,不过我是很新的新手,如果你能帮我写一个完整的getName.aspx,就简直帮了我一个大忙了,麻烦你了,老大!!
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
方法
首先去 http://jquery.com/下载jquery-1.6.4.min.js

在页面中加入
<script src="jquery-1.6.4.min.js" type="text/javascript"></script>


<ItemTemplate>
<div id='d<%#Eval("AGENTID")%>'></div>
<script>
$('d<%#Eval("AGENTID")%>').load('getName.aspx?id=<%#Eval("AGENTID")%>');
</script>
</ItemTemplate>

然后你写一个getName.aspx,把id传进去,自己在getName.aspx里面去查询数据库就可以了。
ssswww5178 2011-10-20
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 accomp 的回复:]
引用 8 楼 ssswww5178 的回复:
引用 3 楼 net_lover 的回复:
数据库里面有,你没有select出来

数据库里面肯定有RealName这列,和上面那个("AGENTNAME")%在同一个表内,这个都能正常读取显示。这套程序没有.cs文件,被封装了的,就是看有其它办法让这个RealName能被读取显示出来,我是大菜鸟,有方法的话请说具体点哈。

贴 sql文
[/Quote]

这个吗?
using System;
using System.Data;
using System.Web;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Utility;
using UUAlly.BLL;
using UUAlly.DAL;
using UUAlly.Entity;
using UUAlly.RBAC;

public class Admin_ChartType_2 : UserControl
{
protected Button btnSelect;
protected Button btnSelectTWeek;
protected UserControl_DateUser DateEnd;
protected UserControl_DateUser DateStart;
protected HtmlGenericControl divLowAgent;
protected HtmlGenericControl divLowUser;
private int flag = 2;
protected GridView gridChartAgent;
protected GridView gridChildAgentChart;
protected GridView gridUserChart;
protected HiddenField hidWhere;
private string lowagent;
private string lowuser;
protected Panel pathList;
protected RadioButtonList rdbtnSelect;
protected HtmlInputText txtID;

private void BindPath(int chartId)
{
string text = " → ";
string gALevelCode = new UUAlly.BLL.GameAgentInfo().GetEntityByGAAgentID(chartId).GALevelCode;
string str3 = SiteIdentity.GetCurrent().UserID.ToString();
gALevelCode = gALevelCode.Substring(gALevelCode.IndexOf("#" + str3 + "#"));
gALevelCode = gALevelCode.Substring(1, gALevelCode.Length - 2);
DataSet set = new UUAlly.BLL.GameAgentInfo().SelectWhereOrderedEx("GAAgentID in (" + gALevelCode.Replace('#', ',') + ")", "GAAgentID asc", "GAAgentID,GAAgentName");
string[] strArray = gALevelCode.Split(new char[] { '#' });
string str4 = string.Empty;
for (int i = 0; i < strArray.Length; i++)
{
string str5 = set.Tables[0].Rows[i][1].ToString();
if (i != 0)
{
this.pathList.Controls.Add(new LiteralControl(text));
}
if (i == (strArray.Length - 1))
{
str4 = "代理" + str5;
}
else
{
if (strArray[i].ToString().Equals("10736"))
{
str5 = "运营商" + str5;
}
else
{
str5 = "代理" + str5;
}
str4 = "<a href=\"AgentInfo.aspx?aid=" + strArray[i] + "\" title='代理'>" + str5 + "</a>";
}
this.pathList.Controls.Add(new LiteralControl(str4));
}
}

protected void btnSelect_Click(object sender, EventArgs e)
{
if (this.txtID.Value.Trim() == "此处输入查询账号")
{
try
{
string stringTime = this.GetStringTime(this.DateStart.Value);
string eTime = this.GetStringTime(this.DateEnd.Value);
CommonDataBind.GVDataBind(this.gridChartAgent, this.gridChildAgentChart, this.gridUserChart, int.Parse(this.hidWhere.Value), stringTime, eTime, out this.lowagent, out this.lowuser, this.flag);
this.DataShow(this.lowagent, this.lowuser);
}
catch
{
MessageBox.Show(this.Page, "请输入正确时间");
}
}
else
{
string str3;
if (this.rdbtnSelect.SelectedItem.Value.Equals("2"))
{
if ((this.txtID.Value != "") && (this.txtID.Value != "此处输入查询账号"))
{
UUAlly.Entity.GameUserInfo entityByLoginName = new UUAlly.BLL.GameUserInfo().GetEntityByLoginName(this.txtID.Value.Trim());
if (entityByLoginName != null)
{
str3 = "/Admin/ChildAgent/UserChartInfo.aspx?id=" + entityByLoginName.GUUserID;
base.Response.Redirect(str3);
}
else
{
MessageBox.Show(this.Page, "查无此账号");
}
}
}
else if ((this.txtID.Value != "") && (this.txtID.Value != "此处输入查询账号"))
{
UUAlly.Entity.GameAgentInfo entityByGAAgentName = new UUAlly.DAL.GameAgentInfo().GetEntityByGAAgentName(this.txtID.Value.Trim());
if (entityByGAAgentName != null)
{
str3 = "/Admin/ChildAgent/AgentChartInfo.aspx?id=" + entityByGAAgentName.GAAgentID;
base.Response.Redirect(str3);
}
else
{
MessageBox.Show(this.Page, "查无此账号");
}
}
}
}

protected void btnSelectTWeek_Click(object sender, EventArgs e)
{
DateTime thisWeek = this.GetThisWeek(DateTime.Now);
CommonDataBind.GVDataBind(this.gridChartAgent, this.gridChildAgentChart, this.gridUserChart, int.Parse(this.hidWhere.Value), thisWeek.ToString(), this.GetNextWeek(thisWeek).ToString(), out this.lowagent, out this.lowuser, this.flag);
this.DataShow(this.lowagent, this.lowuser);
}

private void DataShow(string agnet, string user)
{
this.divLowAgent.InnerHtml = agnet;
this.divLowUser.InnerHtml = user;
}

private int GetDayOfWeek(DateTime dt)
{
switch (dt.DayOfWeek.ToString())
{
case "Monday":
return 1;

case "Tuesday":
return 2;

case "Wednesday":
return 3;

case "Thursday":
return 4;

case "Friday":
return 5;

case "Saturday":
return 6;

case "Sunday":
return 7;
}
return 0;
}

private string GetETime(string value)
{
DateTime time = new DateTime();
try
{
time = DateTime.Parse(value);
}
catch
{
}
return time.ToString();
}

private DateTime GetNextWeek(DateTime dt)
{
return DateTime.Parse(dt.AddDays(7.0).ToShortDateString() + " 12:00:00");
}

private string GetSTime(string value)
{
DateTime time = new DateTime();
try
{
time = DateTime.Parse(value);
}
catch
{
}
return time.ToString();
}

private string GetStringTime(DateTime dt)
{
return (dt.ToShortDateString() + " 12:00:00");
}

private DateTime GetThisWeek(DateTime dt)
{
int num = -this.GetDayOfWeek(dt) + 1;
dt = DateTime.Parse(dt.AddDays((double) num).ToShortDateString() + " 12:00:00");
return dt;
}

protected void gridChildAgentChart_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.gridChildAgentChart.PageIndex = e.NewPageIndex;
CommonDataBind.GVDataBind(this.gridChartAgent, this.gridChildAgentChart, this.gridUserChart, int.Parse(this.hidWhere.Value), this.GetStringTime(this.DateStart.Value), this.GetStringTime(this.DateEnd.Value), out this.lowagent, out this.lowuser, this.flag);
}

protected void gridUserChart_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.gridUserChart.PageIndex = e.NewPageIndex;
CommonDataBind.GVDataBind(this.gridChartAgent, this.gridChildAgentChart, this.gridUserChart, int.Parse(this.hidWhere.Value), this.GetStringTime(this.DateStart.Value), this.GetStringTime(this.DateEnd.Value), out this.lowagent, out this.lowuser, this.flag);
}

protected void Page_Load(object sender, EventArgs e)
{
string queryString = PostGet.GetQueryString("aid");
if ((queryString + "") == "")
{
queryString = SiteIdentity.GetCurrent().UserID.ToString();
}
this.hidWhere.Value = queryString;
this.BindPath(int.Parse(queryString));
if (!base.IsPostBack)
{
this.DateStart.Value = DateTime.Parse(DateTime.Now.ToShortDateString() + " 12:00:00");
this.DateEnd.Value = DateTime.Parse(DateTime.Now.AddDays(1.0).ToShortDateString() + " 12:00:00");
CommonDataBind.GVDataBind(this.gridChartAgent, this.gridChildAgentChart, this.gridUserChart, int.Parse(this.hidWhere.Value), this.GetStringTime(this.DateStart.Value), this.GetStringTime(this.DateEnd.Value), out this.lowagent, out this.lowuser, this.flag);
this.DataShow(this.lowagent, this.lowuser);
}
}

protected HttpApplication ApplicationInstance
{
get
{
return this.Context.ApplicationInstance;
}
}

protected DefaultProfile Profile
{
get
{
return (DefaultProfile) this.Context.Profile;
}
}
}
ssswww5178 2011-10-20
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 net_lover 的回复:]
aspx里面可以通过ajax再去读取这个字段的内容
[/Quote]

怎么加?加在哪里?给段代码嘛,谢谢
ASPNETCHENGXU 2011-10-20
  • 打赏
  • 举报
回复
用Reflector.exe把源代码反编译出来,再改
孟子E章 2011-10-20
  • 打赏
  • 举报
回复
aspx里面可以通过ajax再去读取这个字段的内容
ssswww5178 2011-10-20
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 accomp 的回复:]
引用 8 楼 ssswww5178 的回复:
引用 3 楼 net_lover 的回复:
数据库里面有,你没有select出来

数据库里面肯定有RealName这列,和上面那个("AGENTNAME")%在同一个表内,这个都能正常读取显示。这套程序没有.cs文件,被封装了的,就是看有其它办法让这个RealName能被读取显示出来,我是大菜鸟,有方法的话请说具体点哈。

贴 sql文
[/Quote]

其实问题很简单:就是后台封装了的不能编辑、修改,能不能在aspx通过添加代码,或其它方法来读取和显示RealName这列
huijunliang 2011-10-19
  • 打赏
  • 举报
回复
看下你sql语句 你有没有 as 它。
孟子E章 2011-10-19
  • 打赏
  • 举报
回复
数据库里面有,你没有select出来
laowang134 2011-10-19
  • 打赏
  • 举报
回复
数据源中没有realname这一列。
accomp 2011-10-19
  • 打赏
  • 举报
回复
说的很明确 查看数据源 有“RealName”这列么
ssswww5178 2011-10-19
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 insus 的回复:]
SELECT [RealName],... FROM [tableName]
[/Quote]
大哥,这行代码加到哪里?我太菜了,呵呵,请详细一点。
ycproc 2011-10-19
  • 打赏
  • 举报
回复
select的时候加上就行了
insus 2011-10-19
  • 打赏
  • 举报
回复
SELECT [RealName],... FROM [tableName]
ssswww5178 2011-10-19
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 feng1366259807 的回复:]
查询得到的数据源 没有 RealName 这一列 这和你数据库有没有没关系
[/Quote]
怎样做,请说详细一点,我太菜了
accomp 2011-10-19
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 ssswww5178 的回复:]
引用 3 楼 net_lover 的回复:
数据库里面有,你没有select出来

数据库里面肯定有RealName这列,和上面那个("AGENTNAME")%在同一个表内,这个都能正常读取显示。这套程序没有.cs文件,被封装了的,就是看有其它办法让这个RealName能被读取显示出来,我是大菜鸟,有方法的话请说具体点哈。
[/Quote]
贴 sql文
ssswww5178 2011-10-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 net_lover 的回复:]
数据库里面有,你没有select出来
[/Quote]
数据库里面肯定有RealName这列,和上面那个("AGENTNAME")%在同一个表内,这个都能正常读取显示。这套程序没有.cs文件,被封装了的,就是看有其它办法让这个RealName能被读取显示出来,我是大菜鸟,有方法的话请说具体点哈。
风2013 2011-10-19
  • 打赏
  • 举报
回复
查询得到的数据源 没有 RealName 这一列 这和你数据库有没有没关系
心随莎动 2011-10-19
  • 打赏
  • 举报
回复
你调试一下,看你的datatable里有RealName?
keepfool 2011-10-19
  • 打赏
  • 举报
回复
提供的数据源没有RealName这一列或这一属性。

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧