在网格中添加超链接

发布于 2024-10-10 06:15:20 字数 2536 浏览 1 评论 0原文

我正在构建一个网络应用程序。这需要一个具有向下钻取功能的网格视图。 代码

使用系统 ; 使用系统集合; 使用系统配置; 使用系统数据; 使用 System.Linq; 使用系统.Web; 使用 System.Web.Security; 使用 System.Web.UI; 使用 System.Web.UI.HtmlControls; 使用 System.Web.UI.WebControls; 使用 System.Web.UI.WebControls.WebParts; 使用 System.Xml.Linq; 使用 System.Data.SqlClient; 使用 System.Net.Mail;

公共部分类 PcocDash :System.Web.UI.Page { 字符串 id = 字符串.Empty;

protected void Page_Load(object sender, EventArgs e)
{
    DataTable dtprocdash = new DataTable();

    dtprocdash.Columns.Add("UOM");
    dtprocdash.Columns.Add("Jan");
    dtprocdash.Columns.Add("Feb");
    dtprocdash.Columns.Add("Mar");

#region PRStatus 标头 DataRow dr = dtprocdash.NewRow(); dr["UOM"] = "";

    dtprocdash.Rows.Add(dr);

endregion

区域 PO 数量

    DataRow drprwithsla = dtprocdash.NewRow();
     drprwithsla["UOM"] = "No";                    
            SqlConnection co1 = new SqlConnection();

    co1.ConnectionString = DataBaseOperation.GetConnectioString();
    SqlCommand cmd1 = new SqlCommand();
    cmd1.Connection = co1;
    cmd1.CommandText = strQuery;
    co1.Open();
    //SqlDataReader rd = cmd.ExecuteReader();
    SqlDataReader rd1;
    rd1 = cmd1.ExecuteReader();
    while (rd1.Read())
    {
        drprwithsla[2] = rd1["Jan"].ToString();
        drprwithsla[3] = rd1["Feb"].ToString();

        drprwithsla[4] = rd1["Mar"].ToString();


    }
    co1.Close();

dtprocdash.Rows.Add(drprwithsla);

protected void GridView1_RowDataBound(对象发送者,GridViewRowEventArgs e) if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex == 0) { GridViewRow gvRow = e.Row; gvRow.Cells[0].Text = "公关状态"; gvRow.Cells[0].BackColor = System.Drawing.Color.Yellow; gvRow.Cells[0].Horizo​​ntalAlign = Horizo​​ntalAlign.Left; gvRow.Cells[0].Font.Italic = true; gvRow.Cells[0].Font.Bold = true;

        }
        if (e.Row.RowIndex == 1)
        {
            GridViewRow gvRow = e.Row;
            gvRow.Cells[0].Text = "Total no of PR's";
            gvRow.Cells[0].BackColor = System.Drawing.Color.Wheat;
            gvRow.Cells[0].HorizontalAlign = HorizontalAlign.Right;
            gvRow.Cells[0].Font.Italic = true;
        }

问题

是我在 aspx 页面中创建了一个网格,并且所有列都已添加到 .cs 文件中。请有人帮帮我。如何在此页面添加超链接。我对 .net 真的很陌生。预先感谢您的任何回复

Iam building a web application. which requires a grid view with drill down .
Code

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Net.Mail;

public partial class PcocDash : System.Web.UI.Page
{
string id = string.Empty;

protected void Page_Load(object sender, EventArgs e)
{
    DataTable dtprocdash = new DataTable();

    dtprocdash.Columns.Add("UOM");
    dtprocdash.Columns.Add("Jan");
    dtprocdash.Columns.Add("Feb");
    dtprocdash.Columns.Add("Mar");

#region PRStatus Header
DataRow dr = dtprocdash.NewRow();
dr["UOM"] = "";

    dtprocdash.Rows.Add(dr);

endregion

region No of POs

    DataRow drprwithsla = dtprocdash.NewRow();
     drprwithsla["UOM"] = "No";                    
            SqlConnection co1 = new SqlConnection();

    co1.ConnectionString = DataBaseOperation.GetConnectioString();
    SqlCommand cmd1 = new SqlCommand();
    cmd1.Connection = co1;
    cmd1.CommandText = strQuery;
    co1.Open();
    //SqlDataReader rd = cmd.ExecuteReader();
    SqlDataReader rd1;
    rd1 = cmd1.ExecuteReader();
    while (rd1.Read())
    {
        drprwithsla[2] = rd1["Jan"].ToString();
        drprwithsla[3] = rd1["Feb"].ToString();

        drprwithsla[4] = rd1["Mar"].ToString();


    }
    co1.Close();

dtprocdash.Rows.Add(drprwithsla);

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex == 0)
{
GridViewRow gvRow = e.Row;
gvRow.Cells[0].Text = "PR Status";
gvRow.Cells[0].BackColor = System.Drawing.Color.Yellow;
gvRow.Cells[0].HorizontalAlign = HorizontalAlign.Left;
gvRow.Cells[0].Font.Italic = true;
gvRow.Cells[0].Font.Bold = true;

        }
        if (e.Row.RowIndex == 1)
        {
            GridViewRow gvRow = e.Row;
            gvRow.Cells[0].Text = "Total no of PR's";
            gvRow.Cells[0].BackColor = System.Drawing.Color.Wheat;
            gvRow.Cells[0].HorizontalAlign = HorizontalAlign.Right;
            gvRow.Cells[0].Font.Italic = true;
        }

}

The issue is i have created a grid in aspx page and all the columns have been added in .cs file . Please some one help me out . how to add hyperlink in this page . Iam really new to the .net . Thanks in advance for any response

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

后知后觉 2024-10-17 06:15:20

请尝试使用此代码在网格视图中添加超链接。

Windows 应用程序:

DataGridViewLinkColumn View = new DataGridViewLinkColumn();
View.HeaderText = "";
View.Width = 30;
View.Name = "View";
View.Text = "Print";
gv_CRWS_details.Columns.Insert(0, View);

Web 应用程序:

GridViewLinkColumn View = new GridViewLinkColumn();
    View.HeaderText = "";
    View.Width = 30;
    View.Name = "View";
    View.Text = "Print";
    gv_CRWS_details.Columns.Insert(0, View);

Please try this code to add a hyperlink in grid view.

Windows Application:

DataGridViewLinkColumn View = new DataGridViewLinkColumn();
View.HeaderText = "";
View.Width = 30;
View.Name = "View";
View.Text = "Print";
gv_CRWS_details.Columns.Insert(0, View);

WebApplication:

GridViewLinkColumn View = new GridViewLinkColumn();
    View.HeaderText = "";
    View.Width = 30;
    View.Name = "View";
    View.Text = "Print";
    gv_CRWS_details.Columns.Insert(0, View);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文