对另一列的超链接引用DevExpress Gridview ASP.Net Webform [英] Hyperlink Reference to another column DevExpress Gridview ASP.Net Webform
问题描述
我正在使用for循环,使用VB.Net将列添加到DevExpress ASP.Net WebForms GridView中。我能够获得一个超链接来引用相同的列值:
I'm using a for loop to add columns to the DevExpress ASP.Net WebForms GridView using VB.Net. I was able to get a hyperlink to reference the same column value:
Dim newColumn As New DevExpress.Web.GridViewDataHyperLinkColumn
newColumn.PropertiesHyperLinkEdit.NavigateUrlFormatString = "TrendView.aspx?CurrentID={0}"
我需要以编程方式将超链接设置为另一列的值...即,第三列需要具有引用同一行中列1值的超链接。您如何在运行时使用VB或C#访问该行的另一列?
I need to programmatically set the hyperlink to another column's value... i.e. column three needs to have a hyperlink that references the column 1 value in the same row. How do you access another column in that row using VB or C# during runtime?
推荐答案
请引用此URL解决您的问题
please refer this url to solve your problem
https:// www .devexpress.com / Support / Center / Example / Details / E308
将填充的网格逻辑更改为
change your populate grid logic as
ASPX:
<dx:ASPxGridView ID="ASPxGridView1" runat="server"></dx:ASPxGridView>
CS
protected void Page_Init(object sender, EventArgs e)
{
ASPxGridView1.KeyFieldName = "ID";
ASPxGridView1.DataSource = GetData();
if (!IsPostBack && !IsCallback)
{
PopulateColumns();
ASPxGridView1.DataBind();
}
}
public DataTable GetData()
{
DataTable Table = new DataTable();
Table.Columns.Add("ID", typeof(int));
Table.Columns.Add("ItemName", typeof(string));
Table.Columns.Add("ItemValue", typeof(string));
Table.Rows.Add(1, "A","AA");
Table.Rows.Add(2, "B","BB");
return Table;
}
public void PopulateColumns()
{
GridViewDataTextColumn colID = new GridViewDataTextColumn();
colID.FieldName = "ID";
ASPxGridView1.Columns.Add(colID);
GridViewDataTextColumn srk = new GridViewDataTextColumn();
srk.FieldName = "ItemValue";
ASPxGridView1.Columns.Add(srk);
GridViewDataHyperLinkColumn colItemName = new GridViewDataHyperLinkColumn();
colItemName.FieldName = "ItemValue";
colItemName.PropertiesHyperLinkEdit.NavigateUrlFormatString = "~/details.aspx?Device={0}";
colItemName.PropertiesHyperLinkEdit.TextFormatString = "{0}";
colItemName.PropertiesHyperLinkEdit.TextField = "ItemName";
ASPxGridView1.Columns.Add(colItemName);
}
此处列itemName将itemValue称为url字符串参数
here column itemName refer to itemValue as url string params
这篇关于对另一列的超链接引用DevExpress Gridview ASP.Net Webform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!