我想设置一个动态链接到网格中的列。我通过从webservis阅读来填充.cs文件中的网格我可以显示页面上的数据但不能设置到列的动态链接我该怎么做?
我如何填充网格如下;
public DataTable FillGrid(decimal CurrentUserID)
{
SasBanaUygunIslerEkleRequest sasBanaUygunIslerEkleRequest = new SasBanaUygunIslerEkleRequest();
sasBanaUygunIslerEkleRequest.IstProfilKayitNo = ((int)CurrentUserID);
SasLocalServiceBLL sasLocalServiceBLL = new SasLocalServiceBLL();
ServisSonucBE<List<SasBanaUygunIslerEkleResponse>> resp = sasLocalServiceBLL.BanaUygunIslerEkle(sasBanaUygunIslerEkleRequest);
DataTable dt = new DataTable();
dt.Columns.Add("TALEPNO", typeof(string));
dt.Columns.Add("BASLANGICTARIHI", typeof(string));
dt.Columns.Add("BITISTARIHI", typeof(string));
for (int index = 0; index < resp.Veri.Count; index++)
{
SasBanaUygunIslerEkleResponse var;
DataRow row = dt.NewRow();
if (resp.Veri.ToArray()[index].IstIsgucuIstemiKayitNo != null)
{
row[0] = resp.Veri.ToArray()[index].IstIsgucuIstemiKayitNo;
}
dt.Rows.Add(row);
}
return dt;
}
字符串
我想将链接属性设置为第一个字段。我想根据条件改变链接页。
if (SecurityContext.IsUser && SecurityContext.CurrentUser != null && SecurityContext.CurrentUser.IsInternalUser)
{
object isverenTur = DataBinder.GetPropertyValue(e.Row.DataItem, "ISVERENTUR");
object userId = CurrentQueryHashedUserID;
if (userId != null)
{
literal.Text = string.Format("<a href=\"javascript:PopupJobDetailsImd('{0}','{1}','{2}');\">{0}</a>", isgucuIstemiNo, isverenTur, userId);
}
else
literal.Text = string.Format("<a href=\"javascript:PopupJobDetails('{0}');\">{0}</a>", isgucuIstemiNo);
}
else
{
literal.Text = string.Format("<a href=\"javascript:PopupJobDetails('{0}');\">{0}</a>", isgucuIstemiNo);
}
型
1条答案
按热度按时间iyfjxgzm1#
若要在ASP.NETWebForms中的GridView列中设置动态链接,可以使用TemplateField控件。您可以在TemplateField中定义一个模板,而不是直接将列绑定到数据,从而允许您自定义内容并包含动态链接。
以下是您的操作方法:
字符串
型
型