Q:

how to dynamically give a link download attribute to htmlgeneric control in C#

I am using HTMLgeneric controls for dynamic links and I want to give the link download attribute  when it dynamically added it should be like this in inspect 
<a href="somthing" download>download</a>

my code behind is here 
HtmlGenericControl a = new HtmlGenericControl("a");
a.Attributes.Add("href", ds2.Tables[0].Rows[i][2].ToString());//ds is my dataset 
a.Attributes.Add("download", null);
a.InnerHtml = ds2.Tables[0].Rows[i][1].ToString();

it doesn't work 
how can I fix that 

A:

An attribute is always a KeyValue pair. So if the Value is null the Key won't be added.
a.Attributes.Add("download", "download");

But why a HtmlGenericControl and not a HtmlAnchor Control?
HtmlAnchor a = new HtmlAnchor();
a.InnerText = "download";
a.HRef = ds2.Tables[0].Rows[i][2].ToString();
a.Attributes.Add("download", "download");

Or even a HyperLink Control
HyperLink hl = new HyperLink();
hl.Text = "download";
hl.NavigateUrl = ds2.Tables[0].Rows[i][2].ToString();
hl.Attributes.Add("download", "download");

And don't forget to add the control you created to the Page.
PlaceHolder1.Controls.Add(a);

