如何在选择到数据列表的文本框中显示数据 [英] how can show data in textbox selected to the datalist
本文介绍了如何在选择到数据列表的文本框中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有请检查此代码,并告诉错误在哪里
我将填充数据列表,然后在数据列表行上单击用户
然后在文本框中显示所选项目
请检查此
Dear All pls check this code and tell where the error
i m populate datalist and when click the user on datalist row
then show the selected item on textbox
pls check this
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
LinkButton id = (LinkButton)e.Item.FindControl("lnk");
Label c_type = (Label)e.Item.FindControl("cat");
TextBox1.Text = id.Text;
TextBox2.Text = c_type.Text;
}
}
这是我的源代码
and this is the my source code
<pre lang="xml"><body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataKeyField="ID"
DataSourceID="AccessDataSource1">
<ItemTemplate>
<asp:LinkButton ID="lnkselect" runat ="server" Text=''<%# Eval("ID") %>'' CommandName ="Edit" ></asp:LinkButton>
<asp:Label ID="cat" runat="server" Text=''<%# Eval("cat_type") %>'' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/blog.mdb" SelectCommand="SELECT * FROM [content]">
</asp:AccessDataSource>
<br />
</div>
</form>
</body>
推荐答案
在数据列表的项目命令事件中编写该代码
write that code in item command event of datalist
这篇关于如何在选择到数据列表的文本框中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文