Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with datagrid

Status
Not open for further replies.

Sukhman

Programmer
Sep 17, 2008
2
CA
hi

I am displaying a table in ASP.Net from MS SQL database. I want to create a hyperlink on my first column so that when clicked it shows a new page where details of that client is displayed.

Here is the code:

<!--#include file="dbconnection.aspx"-->
<%@ outputcache Duration="1" varybyparam="none" %>
<script runat="server">
sub Page_Load
if not Page.IsPostBack then
dim ds as dataset

dim mycommand as sqldataadapter
mycommand=new sqldataadapter("select company_name as 'Company Name', first_name as 'First Name', last_name as 'Last Name', record_status as 'Record Status' from add_customer where record_status='Active'",myconnection)
ds=new dataset
mycommand.fill(ds)
if ds.tables(0).rows.count > 0 then

mydatagrid.DataSource=ds.tables(0).defaultView
mydatagrid.DataBind()


end if

myconnection.Close()
end if
end sub
</script>
<html>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#000000">
<% if session("login_status")=true and session("view_right")="Yes" then%>

<table width="992" align="center" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td height="466" valign="top"><table width="992" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="19" colspan="2" bgcolor="#d0da9d"><!--#include file="image.aspx" --></td>
</tr>
<tr>
<td height="19" colspan="2" bgcolor="#7fab07"><!--#include file="menubar.aspx" --></td>

</tr>
<tr>
<td width="221" valign="top" bgcolor="#7fab07"><!--#include file="navigate.aspx" --></td>
<td width="771" height="373" valign="top" bgcolor="#56840c">
<table align="center"><tr><td width="470" >
<form runat="server">
<table width="765" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="765" height="34" valign="middle" background="images/clientlist.jpg"></td>
</tr>
<tr>
<td align="center"><asp:label id="lb1" ForeColor="#FFFFFF" Enabled="false" runat="server"/></td>
</tr>
<tr>
<td><asp:Datagrid id="mydatagrid" Width="765" runat="server" BackColor="#99CCFF" ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="7pt">
<AlternatingItemStyle BackColor="#DBE3BB"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="#FAF8E7"></ItemStyle>
<HeaderStyle Font-Size="7" Font-Bold="True" ForeColor="White" BackColor="#7FAB07"></HeaderStyle>

</asp:datagrid></td>
</tr>
</table>




</form>
</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="6"><img src="images/index_10.jpg" width="992" height="20"></td></tr>
</table></td>
</tr>
</table><%else%>
You must be login or you have no permission to access this page
<%end if%>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top