GridView

L

le0

Guys,

Im a newbies in asp.net and i have this big prob. How can i get the ID or
the primary key of a table? Im using GridView to display all the data. I
want to pass that value to another page using querystring, but how can i get
some value in a GridView. And how can i use hyperlink controls inside a
gridview?

l30
 
R

Rob MacFadyen

Leo,

Can you use databinding on a HyperLinkField:
<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="MyIdField"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
AllowPaging="True"
AllowSorting="True"
GridLines="None">
<Columns>
<asp:HyperLinkField
SortExpression="MyIdField"
HeaderText="ID"
DataNavigateUrlFields="MyIdField"
DataNavigateUrlFormatString="page2.aspx?ID={0}"
DataTextField="DatabaseName" />
</Columns>
</asp:GridView>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:C1 %>"
SelectCommand="SELECT MyIdField FROM Stuff">
</asp:SqlDataSource>

Regards,

Rob MacFadyen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top