gridview从绑定字段获取数据 [英] gridview getting data from bound field
本文介绍了gridview从绑定字段获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是基于文本框标签获取的代码,但我无法进入绑定字段。抱歉我的英语
Dim gvCourse As GridView = DirectCast(sender,GridView)
'获取存储在文本框中的值
Dim strOrderID As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl(lblOrderID),Label).Text
Dim strFreight As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl(txtFreight), TextBox).Text
Dim strShipperName As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl(txtShipperName),TextBox).Text
谢谢
解决方案
CodeProject常见问题系列1 :ASP.NET GridView [ ^ ]可能会帮助你。
你好,
看到这个样本:
in clien t code sample:
< Columns>
< asp:templatefield headerstyle-horizontalalign = 中心 headertext = 查看 >
< itemtemplate> ;
< asp:linkbutton id = viewdata runat = server text = 查看 >
OnClick = viewdata_Click >
< / asp:linkbutton >
< / / span> itemtemplate >
< asp:boundfield datafield = OrderId headertext = 订单ID />
< asp:boundfield datafield = 运费 headertext = 运费 />
< asp:boundfield datafield = ShipperName headertext = 托运人姓名 />
< / 列 >
< / asp:templatefield >
样本背后的代码:
受保护的子viewdata_Click(发件人为对象,e为EventArgs)
Dim viewdata As LinkButton = TryCast(sender,LinkButton)
Dim row As GridViewRow = DirectCast(viewdata.NamingContainer,GridViewRow)
' row.Cells(0)是链接视图按钮.. 。
Dim strOrderID As String = row.Cells(1).Text.Trim()
Dim strFreight As String = row.Cells(2).Text.Trim()
Dim strShipperName As String = row.Cells(3).Text.Trim()
End Sub
希望这可以帮助...
Pl如果有帮助就可以轻松投票,以便其他人可以考虑作为答案...
问候,
GridView编辑使用BoundField更新
http://patilranjeet.blogspot.in /p/aspnet-gridview-edit.html
hello programmers, got a minor question here. As you see I am getting data on a grid view. My problem is how can I get data on a bound field? Please sir help me out
Here are my code in getting based on textbox label but i cannto get on a bound field. Sorry for my english
Dim gvCourse As GridView = DirectCast(sender, GridView) 'Get the values stored in the text boxes Dim strOrderID As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl("lblOrderID"), Label).Text Dim strFreight As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl("txtFreight"), TextBox).Text Dim strShipperName As String = DirectCast(gvCourse.Rows(e.RowIndex).FindControl("txtShipperName"), TextBox).Text
Thanks
解决方案
CodeProject Frequently Asked Questions Series 1: The ASP.NET GridView[^] might help you out.
Hi,
See this sample:
In client code sample:
<Columns> <asp:templatefield headerstyle-horizontalalign="Center" headertext="View"> <itemtemplate> <asp:linkbutton id="viewdata" runat="server" text="View"> OnClick="viewdata_Click"> </asp:linkbutton> </itemtemplate> <asp:boundfield datafield="OrderId" headertext="Order Id" /> <asp:boundfield datafield="Freight" headertext="Freight" /> <asp:boundfield datafield="ShipperName" headertext="Shipper Name" /> </Columns> </asp:templatefield>
In code behind sample:
Protected Sub viewdata_Click(sender As Object, e As EventArgs) Dim viewdata As LinkButton = TryCast(sender, LinkButton) Dim row As GridViewRow = DirectCast(viewdata.NamingContainer, GridViewRow) ' row.Cells(0) is the link view button... Dim strOrderID As String = row.Cells(1).Text.Trim() Dim strFreight As String = row.Cells(2).Text.Trim() Dim strShipperName As String = row.Cells(3).Text.Trim() End Sub
Hope this could help...
Please vote if could help so that others may consider as an answer...
Regards,
GridView Edit Update Using BoundField
http://patilranjeet.blogspot.in/p/aspnet-gridview-edit.html
这篇关于gridview从绑定字段获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文