我有具有多个 Eval 值的 CommandArgument 属性的 ImageButton。当我单击其中一个时,我想将值传递给 ImageButton2_Click 事件,但它不起作用,因为 Command 参数为空。
<div class="sag-re-icerik" id="icerik2" runat="server">Lorem ipsum dolor sit amet, consectetur commodo et convallis et, auctor viverra metus. Aenean pharetra, arcu nec viverra mollis, turpis neque feugiat massa, non dapibus neque nunc ac orci. </div>
<div class="oy-verme">
<div class="yildiz"><asp:ImageButton ID="ImageButton4" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top: 13px; left:6px; float:left; " commandArgument='<%#Eval("sdasdas") + ","+Eval("fafasfa") %>' /></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton5" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton5_Click" Width="20px" style="position: relative; top: 13px; left:8px; float:left;" commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>'/></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton6" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top: 13px; left:10px ; float:left; " commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>' /></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton3" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top:13px; left:12px ; float:left;" commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>' /></div>
<div class="yildiz"> <asp:ImageButton ID="ImageButton2" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top: 13px; left: 14px; float:left;" commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>' /></div>
<div class="oy-sil"><img src="images/oy-sil.png" width="11" height="13" style="position: relative; top: 30px; " /></div>
</div>
</div>
这是代码隐藏:
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
ImageButton objImage = (ImageButton)sender;
string[] commandArgs = objImage.CommandArgument.ToString().Split(new char[] { ',' });
string id = commandArgs[0];
string text = commandArgs[1];
// string s= Imageid.UniqueID.ToString();
//this.baslik2.Text = s;
}