为什么我在ListView控件中使用commandArgument时出现此错误 [英] why i get this error when i use commandArgument in ListView Control

查看:146
本文介绍了为什么我在ListView控件中使用commandArgument时出现此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ListView中,我拿了一个按钮

In ListView I took one Button

<asp:Button ID="btnsubmit" runat="server" Text="SUBMIT" OnClick="btnsubmit_Click" CommandArgument='<%# Eval("id")%>'/>



所以当写 CommandArgument =''<%#Eval(id)%>''/> ;

这里 id 是表Smart_Pin的主键



我收到此错误


so when write CommandArgument=''<%# Eval("id")%>''/>;
here id is primary key of table Smart_Pin

I get this error

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'id'.





解决方法是什么?



What is the solution ?

推荐答案

您将Button绑定到ListView本身,而不是ListViews数据集。



试试这个:

You are binding the Button to the ListView itself, not the ListViews dataset.

Try this:
<![CDATA[<%# DataBinder.Eval (Container.DataItem, "id") %>





CodeProject正在添加<![CDATA [不要复制那部分。



您可能还需要做一个Parent.DataItem ...



CodeProject is adding the <![CDATA[ don''t copy that part.

You might also need to do a Parent.DataItem...


这篇关于为什么我在ListView控件中使用commandArgument时出现此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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