C# 运行时创建的imagebutton中的命令参数不';不行?
您好,我正在创建新的图像按钮,类似这样的东西C# 运行时创建的imagebutton中的命令参数不';不行?,c#,asp.net,visual-studio,gridview,imagebutton,C#,Asp.net,Visual Studio,Gridview,Imagebutton,您好,我正在创建新的图像按钮,类似这样的东西 e.row.cells[0].text= string.empty; //clearing the cells Imagebutton img1= new ImageButton(); img1.Id="imgInput"; img1.ImageUrl="~/sample.jpg"; img1.CommandArgument= varID; // fetching the ID img1.click+= new ImageClickEventHand
e.row.cells[0].text= string.empty; //clearing the cells
Imagebutton img1= new ImageButton();
img1.Id="imgInput";
img1.ImageUrl="~/sample.jpg";
img1.CommandArgument= varID; // fetching the ID
img1.click+= new ImageClickEventHandler(imgInput_Click);
e.row.controls.add(img1)
我已经在gridview rowdatabound事件中编写了上述代码,该事件是
现在在click事件(imgButton_click;在最后一行处理)中,我希望将命令参数值放入会话中
protected void imgInput_Click(object sender, EventArgs e)
{
Session["idvalue"]= imgInput.CommandArgument;
}
但是这里的变量是空的。为什么会这样?我错过了什么
请导游!谢谢您需要使用该活动
示例:
img1.Command += ImageButton_OnCommand;
protected void ImageButton_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Sort" && e.CommandArgument == "Ascending")
Label1.Text = "You clicked the Sort Ascending Button";
else
Label1.Text = "You clicked the Sort Descending Button";
}
您需要使用事件
示例:
img1.Command += ImageButton_OnCommand;
protected void ImageButton_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Sort" && e.CommandArgument == "Ascending")
Label1.Text = "You clicked the Sort Ascending Button";
else
Label1.Text = "You clicked the Sort Descending Button";
}
请原谅我犯了愚蠢的错误。。我自己写的程序,不是复制粘贴的。请原谅我犯了愚蠢的错误。。我自己写的程序&不是复制粘贴。。