您的位置:首页 > 其它

在Gridview的模板里,控件的CommandArgument向后台传递多个参数

2011-08-01 11:44 477 查看
前台的控件的CommandArgument绑定后台的一个public的方法,绑定的方法返回

<asp:LinkButton ID="lbtnViewRz" runat="server" CommandName="ViewRz" CommandArgument='<%#getIdandFlow(Eval("Id"),Eval("FlowId") )%>' ToolTip='<%#Eval("rzxmmc") %>'><%#CommonClass.getContentByLength(Eval("rzxmmc"),10)%></asp:LinkButton>

--后台的方法

#region 返回Id+,+FlowId

/// <summary>

/// 返回Id+,+FlowId

/// </summary>

/// <param name="Id"></param>

/// <param name="FlowId"></param>

/// <returns></returns>

public string getIdandFlow(object Id, object FlowId)

{

string Result = string.Empty;

if (!string.IsNullOrEmpty(Id.ToString())&&!string.IsNullOrEmpty(FlowId.ToString()))

{

Result = Id.ToString() + "," + FlowId.ToString();

}

return Result;

}

#endregion

在绑定控件的GridView1_RowCommand方法里调用

string id = e.CommandArgument.ToString();

string []strTempValue = id.Trim(new char[] { ',' }).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: