日期:2014-05-18  浏览次数:20484 次

(来者有分)特急,关于DataList的选中及取值问题
朋友们:以下为我的DataList项目模板绑定方法:我现在有两个问题请教大家:

第一个问题:我如何才能选中一行;
第二个问题:我如何才能得到选中列中的值(我估计肯定用到FindCtrol()方法),用什么事件?请高手朋友帮忙.

<ItemTemplate>
<TABLE   id= "table2 "   style= "FONT-SIZE:   12px;   CURSOR:   hand "   borderColor= "#efefef "   height= "18 "
cellSpacing= "0 "   cellPadding= "0 "   width= "100% "   bgColor= "white "   border= "0 ">
<TR   onmouseover= "this.bgColor= '#efefef '; "   onmouseout= "this.bgColor= 'white ';   "   vAlign= "middle ">
<TD   width= "10% ">
<asp:LinkButton   id= "Select "   runat= "server "   CommandName= "Select "> 选中 </asp:LinkButton>
</TD>
<TD   width= "20% ">
<DIV   style= "FONT-SIZE:   9pt;   FONT-FAMILY:   宋体 "   align= "left ">
<asp:Label   id= "lblYhdm "   Runat= "server ">
<%#DataBinder.Eval(Container.DataItem, "yhdm ")%>
</asp:Label> </DIV>
</TD>
<TD   width= "20% ">
<DIV   style= "FONT-SIZE:   9pt;   FONT-FAMILY:   宋体 "   align= "left ">
<asp:Label   id= "lblYhbs "   Runat= "server ">
<%#DataBinder.Eval(Container.DataItem, "yhbs ")%>
</asp:Label>
</DIV>
</TD>
<TD   width= "30% ">
<DIV   style= "FONT-SIZE:   9pt;   FONT-FAMILY:   宋体 "   align= "left ">
<asp:Label   id= "lblYhmc "   Runat= "server ">
<%#DataBinder.Eval(Container.DataItem, "yhmc ")%>
</asp:Label>
</DIV>
</TD>
<TD   width= "20% ">
<DIV   style= "FONT-SIZE:   9pt;   FONT-FAMILY:   宋体 "   align= "left ">
<asp:Label   id= "lblYhjc "   Runat= "server ">
<%#DataBinder.Eval(Container.DataItem, "yhjc ")%>
</asp:Label>
</DIV>
</TD>
</TR>
</TABLE>
/ItemTemplate>



------解决方案--------------------
沙发,帮忙顶,下班了
------解决方案--------------------
最好用别用用DataList事件,用行事件或者注册控件事件,最好


------解决方案--------------------
<asp:LinkButton id= "Select " CommandArgument= "123 " runat= "server " CommandName= "Select "> 选中 </asp:LinkButton>
------解决方案--------------------
private void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if(e.CommandName == "select ")
{
DataList1.SelectedIndex = e.Item.ItemIndex;
Response.Write(((Label)e.Item.FindControl( "lblYhmc ")).Text)
}
BindDataList(); //调用重新绑定数据的方法
}
------解决方案--------------------
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "Select ") { Response.Write(e.CommandArgument+