Hello all:
I am trying to populate a GridView with data being read from a call to a web
service. I have seen plenty of examples that simply execute a SQL data
reader, set the Grid data source to the reader, and then call DataBind(),
but I cannot seem to figure out how to build the GridView row by row with
anything except text. I need the 2nd column of the Grid to be a hyperlink or
a button, and this is where I am having an issue. I can build the Grid by
creating a new data table, adding to the data table column by column and
then row by row, and then binding the Grid to the new Data table, but this
only shows plain text.
Using the designer I also tried creating 3 columns in the Grid, the first
one as text, the 2nd as a ButtonField (I also tried a hyperlink), and the
3rd as text, but when I ran the page I ended up with 6 columns, and the ones
I had created in the designer were empty.
I also tried creating a HyperlinkField and also a ButtonField and setting
the cells in the 2nd column to that, but that did not work either.
Any and all advice is greatly appreciated.
John. 2 6368
Hi John,
As far as 6 columns are concerned even though you are adding 3 columns. for
this, you will have to set the AutoGenerateColumns property of the GridView
to false.
And to show hyperlink in one of thet column, you will have to add the
TemplateField in your grid rather than BoundField and then add the Hyperlink
control in the ItemTemplate of that TemplateField column.
Regards,
Manish www.componentone.com
"John Straumann" wrote:
Hello all:
I am trying to populate a GridView with data being read from a call to a web
service. I have seen plenty of examples that simply execute a SQL data
reader, set the Grid data source to the reader, and then call DataBind(),
but I cannot seem to figure out how to build the GridView row by row with
anything except text. I need the 2nd column of the Grid to be a hyperlink or
a button, and this is where I am having an issue. I can build the Grid by
creating a new data table, adding to the data table column by column and
then row by row, and then binding the Grid to the new Data table, but this
only shows plain text.
Using the designer I also tried creating 3 columns in the Grid, the first
one as text, the 2nd as a ButtonField (I also tried a hyperlink), and the
3rd as text, but when I ran the page I ended up with 6 columns, and the ones
I had created in the designer were empty.
I also tried creating a HyperlinkField and also a ButtonField and setting
the cells in the 2nd column to that, but that did not work either.
Any and all advice is greatly appreciated.
John.
Hi Manish:
Thanks for your note. Do you know of a site that shows an example and/or
tutorial covering this topic?
John.
"Manish" <Ma****@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
Hi John,
As far as 6 columns are concerned even though you are adding 3 columns.
for
this, you will have to set the AutoGenerateColumns property of the
GridView
to false.
And to show hyperlink in one of thet column, you will have to add the
TemplateField in your grid rather than BoundField and then add the
Hyperlink
control in the ItemTemplate of that TemplateField column.
Regards,
Manish www.componentone.com
"John Straumann" wrote:
>Hello all:
I am trying to populate a GridView with data being read from a call to a web service. I have seen plenty of examples that simply execute a SQL data reader, set the Grid data source to the reader, and then call DataBind(), but I cannot seem to figure out how to build the GridView row by row with anything except text. I need the 2nd column of the Grid to be a hyperlink or a button, and this is where I am having an issue. I can build the Grid by creating a new data table, adding to the data table column by column and then row by row, and then binding the Grid to the new Data table, but this only shows plain text.
Using the designer I also tried creating 3 columns in the Grid, the first one as text, the 2nd as a ButtonField (I also tried a hyperlink), and the 3rd as text, but when I ran the page I ended up with 6 columns, and the ones I had created in the designer were empty.
I also tried creating a HyperlinkField and also a ButtonField and setting the cells in the 2nd column to that, but that did not work either.
Any and all advice is greatly appreciated.
John. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
I'm wondering if it's possible, outside of the declaration of an ASP.NET 2.0
GridView, to programmatically style individual columns. For example, I might
want to make the text in a particular...
|
by: Brian McClellan |
last post by:
Just wondering if anyone has a simple example of creating a gridview
completely programmatically, i'm not doing anything terribly sophisticated.
When creating the gridview declaratively evertying...
|
by: jm |
last post by:
I have a Gridview with a LinkButton. The button has text from my
database. It is not the datakey of the database, just free form text.
I want to populate another gridview based upon the data in...
|
by: rn5a |
last post by:
I was using a DataView to bind records from a DB table to a DataGrid
using the following code:
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
sqlDapter = New...
|
by: Wayne Deleer |
last post by:
Hi All,
I'm currently working on a project, and I've come to a part where I
want to add data to a GridView. BUT, I want to do it programmatically,
with alot of control over everything. In my...
|
by: cook.jonathan.m |
last post by:
I want to programmatically add a dropdown to each row in a certain
column returned to the gridview by my query. I want to do this
entirely in behind-code. My gridview tag in the page will have...
|
by: =?Utf-8?B?UGF0cmljayBG?= |
last post by:
I have a gridview on the page that i want to dynamically populate with
radiobuttons, so i went out on the net and found something that works
perfectly, it created radionuttons and the postback with...
|
by: Tomasz |
last post by:
Hello Developers,
Here is interesting problem I just came across: how do I wire a GridView
control programmatically?
Here is my sample code using Object Data Source:
protected void...
|
by: NKaufman |
last post by:
<asp:GridView ID="Basic" runat="server"
DataKeyNames="QuestionID,isHeading" AutoGenerateColumns="false"
AllowPaging="true" PageSize="100">
<Columns>
<asp:BoundField Visible="false"...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |