Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2006, 09:08 AM
Authorized User
 
Join Date: Jul 2005
Location: Pune, Maharasthra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in Gridview Cell

Hello everyone!!
this is lalit.Im facing a problem in gridview control.
The problem is in the following line of code in C# code.

dRowBasicPortFolio[2] = "<A href='../EventsCalendar/default.aspx?company=" + dRow[13] + "'>" + dRow[3] + "</a>"

I want to display the content of dRow[3] between 2 plus as a hyperlink in a gridview column in VC# 2005 but its not working.

It is giving the result in string form instead of link to some other web page(say ../EventsCalendar/default.aspx).Iam getting the following string as a result which is

 "<A href='../EventsCalendar/default.aspx?company=" + dRow[13] + "'>" + dRow[3] + "</a>"

on a cell of a specific GridView column.
In short just tell me in which way by using the following code

dRowBasicPortFolio[2] = "<A href='../EventsCalendar/default.aspx?company=" + dRow[13] + "'>" + dRow[3] + "</a>"

how could i get the hyperlink (dRow[3]) get stored in dRowBasicPortFolio[2] DataRow. The problem is the whole string("<A href='../EventsCalendar/default.aspx?company=" + dRow[13] + "' value of dRow[3] ""</a>") is getting getting stored on dRowBasicPortFolio[2] and displayed on cells of a specific gridveiw column.
one thing to mention that iam getting the value of dRow[3] but not as a hyperlink on a gridview column.

I would specifically like to request Mr. DEEPESH JAIN and PLANOIE to carefully consider and solve my problem as they are the most experienced guys in problem solving in the forum
Please help me out if you can. Its very urgent.


  #2 (permalink)  
Old June 14th, 2006, 08:54 AM
Authorized User
 
Join Date: Jun 2005
Location: , , Philippines.
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

You can just use the hyperlinkfield in the GridView control. You just need to set its parameters properly for it to be working the way you want it to. Here's my example.

DataTable dt = new DataTable();
        dt.Columns.Add("linktext");
        dt.Columns.Add("linktarget");
        for (int i = 0; i < 5; i++)
        {
            dt.Rows.Add(new string[] {"google", "http://www.google.com"});
        }

        GridView1.DataSource = dt;
        HyperLinkField hfield = ((HyperLinkField)GridView1.Columns[0]);
        hfield.DataNavigateUrlFields = new string[]{dt.Columns[0].ColumnName,dt.Columns[1].ColumnName};
        hfield.DataNavigateUrlFormatString = "{1}";
        hfield.DataTextField = hfield.DataNavigateUrlFields[0];
        GridView1.DataBind();


I basically create a gridview control and add a hyperlinkfield. Paste this code into the PageLoad event and see how it work.

Hope this helps.

Aldwin Enriquez
"Dont you ever give up!"
  #3 (permalink)  
Old August 1st, 2007, 04:08 AM
Registered User
 
Join Date: Aug 2007
Location: pune, Maharashtra, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prashantbhale11
Default

you r code is not working properly
it gives error:invallid argument at line HyperLinkField hfield = ((HyperLinkField)GridView1.Columns[0]);
also check this :
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


prashant bhale
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
GridView - cell wrapping - need help snufse ASP.NET 2.0 Basics 0 July 21st, 2008 04:53 PM
Accessing one cell from gridview Aker C# 1 May 22nd, 2008 03:13 PM
How to change the value of one cell in a GridView? jameslin288@yahoo.com ASP.NET 2.0 Basics 8 November 19th, 2006 01:12 PM



All times are GMT -4. The time now is 07:00 PM.


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