数据列表视图命令 [英] datalist view command

查看:80
本文介绍了数据列表视图命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:DataList ID="dlstEmployees" runat="server" CellPadding="4"

        ForeColor="#333333" Width="233px">
    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <AlternatingItemStyle BackColor="White" />
    <ItemStyle BackColor="#E3EAEB" />
    <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<ItemTemplate>

  <%#DataBinder.Eval(Container.DataItem,"FirstName") %>
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/ViewDetails.aspx"

        Target="_search">View</asp:HyperLink>
</ItemTemplate>
</asp:DataList>



当我单击查看时我想查看该用户配置文件..(即,要检索数据列表中的sql(使用sqldatasource的nt)数据(我的意思是我要检索tat用户信息)


在veiw



when i click to view i want to view that user profile ..(i.e want to retrieve sql(nt using sqldatasource) data in datalist(i mean i want to retrieve tat user information)


in veiw

推荐答案

中,只需将用户ID作为查询字符串传递即可,然后您可以从Sql获取用户详细信息并在任何控件中显示

NavigateUrl="~/ViewDetails.aspx?empid=10"
Just pass user id as query string and then you can get user deatils from Sql and show in any control

NavigateUrl="~/ViewDetails.aspx?empid=10"


您可以使用LinkBut​​ton代替HyperLink,否则,如果要使用HyperLink,则必须在HyperLink中使用QueryString.
通过LinkBut​​ton
< asp:LinkBut​​ton id ="LinkBut​​ton1" Text ="View" CommandName ="Dis" CommandArgument =''<%#Eval("FirstName")%>''>

在CodeBehind文件中,您必须创建一个类似如下的函数:::::::::
受保护的void Display(object o,EventArgs e)
{
if(e.CommandName =="Dis")
{
Sql ="Select * from TableName where FirstName =''" +(e.CommandArgument).ToString()+''";

-现在在此处编写您的其他代码(绑定记录)------------
}
}
You can use LinkButton instead of HyperLink otherwise if you want to use HyperLink then you have to use QueryString in HyperLink.
Through LinkButton
<asp:LinkButton id="LinkButton1" Text="View" CommandName="Dis" CommandArgument=''<%#Eval("FirstName")%>''>

In CodeBehind file you have to create a function like this::::::::
protected void Display(object o, EventArgs e)
{
if(e.CommandName=="Dis")
{
Sql="Select * from TableName where FirstName=''"+(e.CommandArgument).ToString()+"''";

-- Now write your further code here (Bind record) ------------
}
}


这篇关于数据列表视图命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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