Hello,
I have a Windows form with a datagrid control, and would like one column to
appear as a hyperlink, so when clicking on it, it will open IE and go to the
web. Unfortunately, I cannot find an example. My code is below.
Essentially what I am trying to do is get a list of patches installed on a
system (via WMI), and display them in a datagrid, with the last column being
a link. The RemoveChars function simply removes alphabetic characters from
the KB article to complete the formation of the link. I have tried using
System.LinkButton and System.RichTextBox as they seem to have some link
abilities to no avail, as it errors saying the data type cannot be null.
Any help or ideas would be greatly appreciated!
Paul
DataTable table = new DataTable("Updates");
DataColumn IDColumn = new DataColumn("Hot Fix
ID",System.Type.GetType("System.String"));
DataColumn DescriptionColumn = new
DataColumn("Description",System.Type.GetType("Syst em.String"));
DataColumn FixCommentsColumn = new DataColumn("Service Pack In
Effect",System.Type.GetType("System.String"));
DataColumn LinkColumn=new
DataColumn("Link",System.Type.GetType("System.Stri ng"));
table.Columns.Add(IDColumn);
table.Columns.Add(DescriptionColumn);
table.Columns.Add(FixCommentsColumn);
table.Columns.Add(LinkColumn);
foreach(ManagementObject oReturn in oReturnCollection)
{
DataRow row = table.NewRow();
row["Hot Fix ID"]=oReturn["HotFixID"].ToString();
row["Description"]=oReturn["Description"].ToString();
row["Service Pack In Effect"]=oReturn["ServicePackInEffect"].ToString();
row["Link"]="http://support.microsoft.com/default.aspx?scid=kb;en-us;"+Remov
eChars(oReturn["HotFixID"].ToString());
table.Rows.Add(row);
}
dgKB.DataSource=table;
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Updates";
dgKB.TableStyles.Clear();
dgKB.TableStyles.Add(ts);