如何使用asp.net在gridview中添加按钮 [英] how to add button in gridview using asp.net

查看:733
本文介绍了如何使用asp.net在gridview中添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gridview中添加按钮,因为我在源页面中编写了如下代码



< asp:TemplateField HeaderText =Course1>

< itemtemplate>

< asp:Button ID =BtncourseHeight =15pxWidth =40pxBorderStyle =NoneOnClick =Btncourse_Click

runat =serverText ='<%#Bind(Course)%>'/>









为此我写了上面的代码,当我运行时显示错误如下



DataBinding:'System.Data.DataRowView'不包含名为'Course'的属性。





有什么问题在上面的代码中。





请帮帮我。



Rgds ,

Narasiman P.

解决方案

试试这个:



创建自己的GridView控件 - ALT.Net的方式 [ ^ ]



http://forums.asp.net/t/1234622.aspx [ ^ ]


< blockquote> Course是DataField,它将绑定您传递给gridview的数据源中的数据。检查数据源是否有任何名称为Course的字段。 课程字段的值将是按钮文本。再次检查您的要求


Add Button in gridview, for that i written the code in source page as follows

<asp:TemplateField HeaderText="Course1">
<itemtemplate>
<asp:Button ID="Btncourse" Height="15px" Width="40px" BorderStyle="None" OnClick="Btncourse_Click "
runat="server" Text='<%#Bind("Course") %>'/>




for that i written a code above, when i run shows error as follows

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


what is the problem in my above code.


please help me.

Rgds,
Narasiman P.

解决方案

try this:

Create Your Own GridView Control - the ALT.Net's Way[^]

http://forums.asp.net/t/1234622.aspx[^]


Course is the DataField which will bind the data from the datasource which you pass to the gridview. Check the Datasource whether you having any field with names as Course. The value of the Course field will be the Button text. Check your requirement once again


这篇关于如何使用asp.net在gridview中添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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