473,834 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hyperlink a field in gridview - ASP.NET

23 New Member
I have a column on a grid view I read in froma DB. The field has 2 values true or false. Now if i click on the field i want the gridview and the DB updated to the new value. I click on true on a row and it changes it to false after it has reloaded the page just on that row.

In PHP you just make a field a hyperlink and send data to another page to update and automatically go back and refresh the page .

In asp.net can i do the saem thing or better?
q1)how do i make a value clickable and i can get the whole row details from that?
Mar 18 '08 #1
3 1496
DrBunchman
979 Recognized Expert Contributor
Hi Jagguy,

This is a classic ASP forum and as your question relates to ASP.NET you'll receive better advice in the .NET forum.

In answer to your question, there are a couple of ways to do this but the Grid View provides an easy in-built way to update bound data. Basically you set the AutoGenerateEdi tButton property to true (this generates a column with an edit button) and then define the sql update command to use when the update button is clicked.

There is an explanation of the various features of a GridView here which has a good example of this.

This is a simple way which doesn't exactly match your original requirement but I suggest that if you want to go down a different route you try a bit of google or post your question in the .NET forum.

Hope this helps,

Dr B
Mar 18 '08 #2
malav123
217 New Member
Hi,
You can accomplish your desired task easily by using asp.net, you just have to take link button in your gridview....
And from the aspx page pass the id or any field and you can use that passed field in gridview and by using that field you can change the gridview row as well as database..
I think this will helps u....
Mar 19 '08 #3
jagguy
23 New Member
q1)how do set the commandargument to a row index in the form? i have spent ages on this simple problem.

I copied this from msdn and it fails .

Expand|Select|Wrap|Line Numbers
  1.  Protected Sub GridView1_RowCreated1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
  2.         If e.Row.RowType = DataControlRowType.DataRow Then
  3.  
  4.              Dim addButton As LinkButton = CType(e.Row.Cells(0).Controls(0), LinkButton)
  5. 'Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.LinkButton'."
  6.             addButton.CommandArgument = e.Row.RowIndex.ToString()
  7.  
  8.         End If
  9.     End Sub
  10.  
Mar 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3670
by: Marcial | last post by:
Hello, I have a ASP.NET 2.0 coding issue I need help with. I have a Gridview which displays the Name and e-mail address columns of an underlying SQL datasource. I added a hyperlink field to the columns collection. I'm trying to figure out how to send an email after the email address link
3
3556
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
1
2102
by: Carlos | last post by:
Hi all, I need a field that it is both databound, and hyperlink in a gridview. That is, the value is obtained from a query, and at the same time needs to point to a new page where will be used to make another query. How can this be possible in asp .net? Thanks in advance, Carlos.
3
4179
by: Bren | last post by:
Hi All VS2005 Gridview control with vb I am populating a gridview of company staff. One of the columns is a hyperlink to a SMS texting facility I have so secrataries can text the managers etc. i.e Secratary loads the page on the intranet, finds the manager they want to contact, clicks on the "SMS" hyperlink and is taken to the SMS page to fill out the message and send it to the manager.
3
3136
by: William LaMartin | last post by:
I have a gridview (with no properties set) on an aspx page which I populate from an XML file with the code below. The data in the XML file looks like this <description>National Trust for Historic Preservation</description> <URL>http://www.nthp.org/</URL> <category>Architecture</category> Can anyone tell me why the other two columns are displayed, but the
3
3071
by: shapper | last post by:
Hello, In my GridView I have a HyperLink Field where I set the DataNavigateUrlFormaString MyHyperLinkField.DataNavigateUrlFormatString = "~\RSS.ashx?Channel={0}&Culture=" & System.Threading.Thread.CurrentThread.CurrentCulture.ToString() I believe {0} retrieves the value of my datasource column with index 0.
1
13850
by: Frank Milverckowitz | last post by:
Hi, I'm trying to do something common and what should be simple using the GridView "Add Columns" feature in Visual Studio 2005. All I want to do is add a Hyperlink column that will take the user to another aspx page for editing (I'm not using the built in edit feature because I have too many columns)
1
7198
by: Valli | last post by:
Hi, I need to display an hyperlink column in gridview where if the user clicks that column the page should move to the selected page. I have got help from this group & started using template field. After using this, I couldnt see a column supporting hyperlink. In the gridviews first column header, there appears an hyperlink with the first record link displaying. That also only in header overwriting with the first column caption.
1
2523
by: Paul W Smith | last post by:
The text below is a GridView I am trying to use to display some data from a database. I am using one templatefield of grid because I want the contents of the record fields to appear on three different lines. Everything works except I now want to add an image with which acts as a hyperlink to another page. The querystring to the new page is a field from the database. What I cannot get right is the syntax to build the Hyperlink to the...
1
3062
by: Author | last post by:
I got into trouble with this problem. The data I am presenting in a GridView control has a column called "Website". That data comes from a stored procedure in SQL Server 2000. Most of them have valid http urls. But some of them say "None" or "Not available". In the GridView, I would like create a hyperlink for those valid http urls only, and simply plain-output those which say "None" or "Not available".
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10214
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9329
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6952
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.