Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2005, 07:00 PM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do you make a Data Grid Hyperlink Column pass

How do you make a Data Grid Hyperlink Column pass information from two columns in the database?

The Datagrid Property Builder allows me to insert anything in the URL Field, but when I put date, category in the URL Field I receive an error.


Can anyone provide me with some help?

 
Old January 13th, 2005, 09:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What error did you receive?

 
Old January 13th, 2005, 10:25 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by stu9820
 What error did you receive?

I tried it using & and received this error:

A field or property with the name 'category&date' was not found on the selected datasource.

Is there a way for it to recognize two fields?



 
Old January 13th, 2005, 10:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post your code?

 
Old January 13th, 2005, 11:40 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by stu9820
 Can you post your code?

Sure, but this is where I'm speaking of is in the Data Grid Property Builder

public class MonthControl : System.Web.UI.UserControl
    {
        protected System.Web.UI.WebControls.DataGrid DataGrid1;
        protected string smonthnumber;
        protected string syearnumber;
        //protected System.Web.UI.WebControls.DataGridItem syearnumber;
        //Open Connection
        SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["MyConn"]);
        protected System.Web.UI.WebControls.HyperLink MonthLink;
        SqlCommand objComm = new SqlCommand();
        SqlDataReader objRead;

        //char nYear;

        public string MonthNumber
        {
            get {return smonthnumber;}
            set {smonthnumber= value;}
        }

        public string YearDate
        {
            get {return syearnumber;}
            set {syearnumber = value;}
        }




        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here

            // nYear=char.Parse(Request["@Year"].ToString());
        }



        #region BindGrid()
        public void BindGrid()
        {

            objComm.CommandText = "sp_myStoredProcedure";
            objComm.CommandType = CommandType.StoredProcedure;
            objComm.Connection = objConn;
            objComm.Parameters.Add("@Month",SqlDbType.Char,2);
            objComm.Parameters["@Month"].Value = smonthnumber;
            objComm.Parameters.Add("@Year",SqlDbType.Char,4);
            //Change 1-11-05
            objComm.Parameters["@Year"].Value = syearnumber;
            //Change
            objComm.Connection.Open();
            DataGrid1.DataSource = objComm.ExecuteReader();

            DataGrid1.DataBind();

            objComm.Connection.Close();
            objComm.Parameters.Clear();

            MonthLink.NavigateUrl="monthabc.aspx?month=" + smonthnumber.ToString() +
                "&syearnumber="+syearnumber.ToString();





 
Old January 13th, 2005, 11:43 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is it possible to create a Hyperlink Column here in the code behind?

Private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{

}







Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink url too long in data grid. Hughesie78 ASP.NET 2.0 Professional 2 May 12th, 2008 11:54 AM
export data grid hyperlink column to excel phyzie VS.NET 2002/2003 0 April 16th, 2007 01:45 AM
How to sort a column in data grid: kenn_rosie ASP.NET 1.0 and 1.1 Basics 1 January 26th, 2006 02:03 PM
Data Grid Drop Down List Column bmains ASP.NET 1.0 and 1.1 Professional 4 September 21st, 2004 08:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.