在服务器端绑定数据列表 [英] bind datalist on server side
问题描述
大家好,
我有一个数据列表,其中有1行.我要根据情况获取该行的值.所以我在服务器端编写了一个过程,并从客户端调用它.像这样
hi all,
I have a datalist and in that I have 1 row. I want the value of that row according to the situation. So i wrote a procedure on server side and calling it from client side. Like this.
<td >
<% WriteMessage()%>
</td>
服务器端代码就是这样...
And server side code is something like this...
Public Sub WriteMessageLink()
Dim str As String = ""
str = "Viewed On : " & dtTemp.Rows(0)("VISITDATE")
Response.Write(str)
End Sub
这里的问题是它将仅占据数据表的第一行并在客户端显示.我想要类似数据列表中的5个项目,那么对于第一个项目,它应该类似于dtTemp.Rows(0)("VISITDATE"),对于第二个项目dtTemp.Rows(1)("VISITDATE")
依此类推....任何人都可以建议我如何编写这样的代码?
提前考虑一下……
Here the problem is it will just take first row of the datatable and display on client side. I want something like if there are 5 items in datalist then for first item it should be like dtTemp.Rows(0)("VISITDATE") for second item dtTemp.Rows(1)("VISITDATE")
and so on.... Any one can suggest how can i write a code like that??
Thnax in advance......
推荐答案
,您可以在数据列表中找到该项目的选定索引.
在按钮上单击
Button btnSave =(Button)sender;
DataListItem项目=(DataListItem)btnSave.NamingContainer;
int index = item.ItemIndex;
by this you can find the selected index of the item in the datalist.
this is on the button click
Button btnSave = (Button)sender;
DataListItem item = (DataListItem)btnSave.NamingContainer;
int index = item.ItemIndex;
这篇关于在服务器端绑定数据列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!