开发者

To add hyperlink in grid

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].Te开发者_如何学运维xt = "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


Add a Hyperlink field

read more here :http://authors.aspalliance.com/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx

and here: How do I programmatically fill a gridview's bound (hyperlink) column dynamically and then use the column's value as the url?


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜