So here is the code and i have the following problem, i don't know how to create a hyperlink object for the column.
所以这里是代码,我有以下问题,我不知道如何为列创建超链接对象。
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("Име на настанот", typeof(string)));
dt.Columns.Add(new DataColumn("Информации за настанот", typeof(string)));
dt.Columns.Add(new DataColumn("Локација", typeof(string)));
dt.Columns.Add(new DataColumn("Време и датум на настанот", typeof(string)));
dt.Columns.Add(new DataColumn("Измени", typeof(HyperLink)));
dt.Columns.Add(new DataColumn("Бриши", typeof(string)));
foreach (Google.GData.Calendar.EventEntry entry in calFeed.Entries)
{
HyperLink a = new HyperLink();
a.NavigateUrl = "aaa";
dr = dt.NewRow();
dr["Име на настанот"] = entry.Title.Text.ToString();
dr["Информации за настанот"] = entry.Content.Content.ToString();
dr["Локација"] = entry.Locations[0].ValueString.ToString();
dr["Време и датум на настанот"] = "Почеток: " + entry.Times[0].StartTime.ToString() + " Крај: " + entry.Times[0].EndTime.ToString();
dr["Измени"] = a.NavigateUrl; //what to add here how to add a hyperlink
dt.Rows.Add(dr);
ViewState["CurrentTable"] = dt;
GridView1.DataSource = dt;
GridView1.DataBind();
}
The error i get is:
我得到的错误是:
The XML element 'EnableTheming' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.
名称空间''中的XML元素'EnableTheming'已存在于当前作用域中。使用XML属性为元素指定另一个XML名称或命名空间。
2 个解决方案
#1
2
Make that column a normal string:
使该列成为普通字符串:
dt.Columns.Add(new DataColumn("Измени", typeof(String)));
Then you can simple assign an HTML code for the link:
然后,您可以简单地为链接分配HTML代码:
dr["Измени"] = "<a href='aaa'>Click Here</a>";
#2
0
You might have to use the RowDataBound event. Or use the <asp:TemplateField> in your grid, this way you can add custom html into a column.
您可能必须使用RowDataBound事件。或者在网格中使用
#1
2
Make that column a normal string:
使该列成为普通字符串:
dt.Columns.Add(new DataColumn("Измени", typeof(String)));
Then you can simple assign an HTML code for the link:
然后,您可以简单地为链接分配HTML代码:
dr["Измени"] = "<a href='aaa'>Click Here</a>";
#2
0
You might have to use the RowDataBound event. Or use the <asp:TemplateField> in your grid, this way you can add custom html into a column.
您可能必须使用RowDataBound事件。或者在网格中使用