Hi Team,
I have a listview that loads perfectly. The listview has about 4 columns; the last column has two image buttons. Each of which takes in an id as the command argument. What I would like to happen is the image button to be hidden depending on the area id. The challenge at the moment is the fact that I am unable to get the command argument value.
I have attached the image button line from the aspx page and the code from the c#
protected void Imgproc_Load(object sender, EventArgs e)
{
ImageButton img = (ImageButton)sender;
string areaid = img.CommandArgument.ToString();
try
{
DataSet ds = new DataSet();
ds = ActionController.GetInfo("Select Top 1 * from BillRunConfigurationTbl where BillCycleID = '"+ddlcycle.SelectedItem.Text.ToString()+"' AreaID = '"+ Convert.ToInt64(areaid)+"' and BillRunStatus like 'Completed'", "DataResults");
if (ActionController.IsMyRowCorrect(ds, "DataResults") == true)
{
img.Visible = false;
}
else {
img.Visible= true;
}
}
catch {
}
}
protected void ImgRev_Load(object sender, EventArgs e)
{
ImageButton img = (ImageButton)sender;
string areaid = img.CommandArgument.ToString();
//img.Visible = false;
try
{
DataSet ds = new DataSet();
ds = ActionController.GetInfo("Select Top 1 * from BillRunConfigurationTbl where BillCycleID = '" + ddlcycle.SelectedItem.Text.ToString() + "' AreaID = '" + Convert.ToInt64(areaid) + "' and BillRunStatus like 'Completed'", "DataResults");
if (ActionController.IsMyRowCorrect(ds, "DataResults") == true)
{
img.Visible = true;
}
else
{
img.Visible = false;
}
}
catch
{
}
}
<asp:ImageButton ID="Imgproc" ToolTip="Click to perform bill run for this area" ImageUrl="~/imgicons/bprocess.png" Height="40px" Width="40px" OnLoad="Imgproc_Load" CommandArgument='<% #Eval("AreaID") %>' AlternateText="Process" runat="server" />
<asp:ImageButton ID="Imgrev" ToolTip="Click to reverse bill run for this area" ImageUrl="~/imgicons/reverse1.png" Height="40px" Width="40px" OnLoad="ImgRev_Load" CommandArgument='<% #Eval("AreaID") %>' AlternateText="Run" runat="server" />