如何在ASP.NET中基于另一个datalist控件单击更改datalist控件文本
亲爱的朋友们,
当我点击另一个datalist2按钮时,我想更改一个datalist1标签文本是否可能......?它是..如何分享样品链接
请帮助我...我希望你理解我的问题,谢谢你
我尝试过:
< asp:DataList ID =datalist1OnItemCommand =dl_beers_ItemCommand Width =100%CellSpacing =10DataKeyField =pidItemStyle-HorizontalAlign =CenterRepeatDirection =VerticalRepeatColumns =1RepeatLayout =Tablerunat =server>
$ b
< asp:DataList ID =datalist2OnItemCommand =dl_beers_ItemCommandWidth =100%CellSpacing =10DataKeyField =pidItemStyle-HorizontalAlign =CenterRepeatDirection =VerticalRepeatColumns =1RepeatLayout =Tablerunat =server>
hi my dear friends,
i would like to change one datalist1 lable text when i am click on another datalist2 button is it possible...? it it is ..how can share that sample link
please help me...i hope u understand my question,thank you
What I have tried:
<asp:DataList ID="datalist1" OnItemCommand="dl_beers_ItemCommand" Width="100%" CellSpacing="10" DataKeyField="pid" ItemStyle-HorizontalAlign="Center" RepeatDirection="Vertical" RepeatColumns="1" RepeatLayout="Table" runat="server">
<asp:DataList ID="datalist2" OnItemCommand="dl_beers_ItemCommand" Width="100%" CellSpacing="10" DataKeyField="pid" ItemStyle-HorizontalAlign="Center" RepeatDirection="Vertical" RepeatColumns="1" RepeatLayout="Table" runat="server">
如果你有一个按钮你的第二个DataList然后你可以做这样的事情(服务器端方法):
If you have a Button in your second DataList then you can do something like this (server-side approach):
protected void Button1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
DataListItem item = (DataListItem)btn.NamingContainer;
if (item != null)
{
//accessing the first Label control within your first DataList
//You may need to change the index of items based on your requirement
Label lbl = (Label)DataList1.Items[0].FindControl("YourLabelID");
lbl.Text = "Some text here";
}
}