日期:2014-05-17 浏览次数:20420 次
<asp:DataList ID ="dtl" runat ="server" RepeatColumns ="5" DataKeyField ="id"
onitemcommand="subCom" onitemdatabound="bindData" >
<ItemTemplate>
<asp:Label ID="lbl_name" runat="server" Text="Label"></asp:Label>
<br />
<asp:TextBox ID="txt_score" runat="server"></asp:TextBox>
<asp:LinkButton ID="lbtn_submit" CommandArgument ='<%#Eval("id") %>' CommandName ="submit" runat="server">提交</asp:LinkButton>
</ItemTemplate>
</asp:DataList>
protected void subCom(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "submit")
{
string id = e.CommandArgument.ToString();
TextBox txtScore = e.Item.FindControl("txt_score") as TextBox;
Label lblName = e.Item.FindControl("lbl_name") as Label;
string strName = lblName.Text;
string strScore = txtScore.Text;
//以下为数据库操作
}
}
protected void bindData(object sender, DataListItemEventArgs e)
{
//绑定数据
}