|
 |
aspx_beginners thread: Creating Links with asp.net
Message #1 by "Adam Harris" <adam@w...> on Thu, 11 Apr 2002 01:54:09 -0400
|
|
Hello,
I hope I can explain what I need to do. When I am pulling records out of a
database, I am using the datagrid controls to display the data. But in each
row, I would like to add another field that will allow the user to click and
go to another script with the id field from each row in it. In asp I would
have accomplished this as follow (pseudocode)
select id, name, email from table
for each row
create link to viewlead.asp?id=rs("id"), display name, display email
movenext
loop
I am not understanding how asp.net creates the viewlead.asp?id part for each
row. Thanks for the help!
Adam Harris
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Thu, 11 Apr 2002 01:09:44 -0700
|
|
Adam,
Set the AutoGenerateColumns attribute of your datagrid to false.
Then, on the ASP.NET page insert a <Columns>-tag in the Datagrid, then
insert a <asp:HyperLinkColumn>-tag in the <Columns>-tag with the
following attributes:
DataNavigateUrlField="id" and
DataNavigateUrlFormatString="viewlead.asp?id={0}"
So your final DataGrid might look something like this:
<asp:DataGrid id="DevicesTable" runat="server"
AutoGenerateColumns="False">
<HeaderStyle Font-Bold="True" BackColor="#E0E0E0"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="strEmail" HeaderText="Email
Address">
</asp:BoundColumn>
<asp:BoundColumn DataField="strName" HeaderText="Name">
</asp:BoundColumn>
<asp:HyperLinkColumn DataNavigateUrlField="id"
DataNavigateUrlFormatString="viewlead.asp?id={0}" DataTextField="id"
HeaderText="ID"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>
Hope it works,
Minh.
-----Original Message-----
From: Adam Harris [mailto:adam@w...]
Sent: Wednesday, April 10, 2002 10:54 PM
To: aspx_beginners
Subject: [aspx_beginners] Creating Links with asp.net
Hello,
I hope I can explain what I need to do. When I am pulling records out
of a
database, I am using the datagrid controls to display the data. But in
each
row, I would like to add another field that will allow the user to click
and
go to another script with the id field from each row in it. In asp I
would
have accomplished this as follow (pseudocode)
select id, name, email from table
for each row
create link to viewlead.asp?id=rs("id"), display name, display email
movenext
loop
I am not understanding how asp.net creates the viewlead.asp?id part for
each
row. Thanks for the help!
Adam Harris
Message #3 by "Adam Harris" <adam@w...> on Fri, 12 Apr 2002 01:56:27 -0400
|
|
Minh, thank you for the help. It worked like a charm. I have two other
questions. When I use the code you gave me, I cause the number out of the
database to show up on my page. Instead, I would like the text "View Leads"
to show up. Is there another field I can add that will allow me to do this?
Also, I would like to add a radio button to each row with the id in it.
Asp.net keeps telling me it's not in the datagrid collection. Could
someone, please help further. You guys are great! Have a great day!
Adam Harris
-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Thursday, April 11, 2002 4:10 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: Creating Links with asp.net
Adam,
Set the AutoGenerateColumns attribute of your datagrid to false.
Then, on the ASP.NET page insert a <Columns>-tag in the Datagrid, then
insert a <asp:HyperLinkColumn>-tag in the <Columns>-tag with the
following attributes:
DataNavigateUrlField="id" and
DataNavigateUrlFormatString="viewlead.asp?id={0}"
So your final DataGrid might look something like this:
<asp:DataGrid id="DevicesTable" runat="server"
AutoGenerateColumns="False">
<HeaderStyle Font-Bold="True" BackColor="#E0E0E0"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="strEmail" HeaderText="Email
Address">
</asp:BoundColumn>
<asp:BoundColumn DataField="strName" HeaderText="Name">
</asp:BoundColumn>
<asp:HyperLinkColumn DataNavigateUrlField="id"
DataNavigateUrlFormatString="viewlead.asp?id={0}" DataTextField="id"
HeaderText="ID"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>
Hope it works,
Minh.
-----Original Message-----
From: Adam Harris [mailto:adam@w...]
Sent: Wednesday, April 10, 2002 10:54 PM
To: aspx_beginners
Subject: [aspx_beginners] Creating Links with asp.net
Hello,
I hope I can explain what I need to do. When I am pulling records out
of a
database, I am using the datagrid controls to display the data. But in
each
row, I would like to add another field that will allow the user to click
and
go to another script with the id field from each row in it. In asp I
would
have accomplished this as follow (pseudocode)
select id, name, email from table
for each row
create link to viewlead.asp?id=rs("id"), display name, display email
movenext
loop
I am not understanding how asp.net creates the viewlead.asp?id part for
each
row. Thanks for the help!
Adam Harris
Message #4 by nguyentriminh@y... on Sat, 13 Apr 2002 21:09:14
|
|
Adam,
>When I use the code you gave me, I cause the number out of the
> database to show up on my page. Instead, I would like the text
> "View Leads" to show up. Is there another field I can add that
> will allow me to do this?
Try the following. I think this should work, I don't have access to a .NET
computer right now to test this, but this should work:
<asp:HyperLinkColumn DataNavigateUrlField="id"
DataNavigateUrlFormatString="viewlead.asp?id={0}" Text="View Leads"
HeaderText="Link"></asp:HyperLinkColumn>
Good luck! As for adding radio buttons, sorry, I don't know how to do
this. Check out gotdotnet.com or post your question there again. I find
that place to be very resourceful.
Minh.
|
|
 |