在datagrid里添加
<asp:TemplateColumn HeaderText="详细" ItemStyle-HorizontalAlign="center" ItemStyle-Width="50" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="linkbtnDetail" Runat="server" CommandName="detail">详细 </asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>在后台编辑datagrid 的 ItemCommand事件
用javascript显示新的页面
<asp:TemplateColumn HeaderText="详细" ItemStyle-HorizontalAlign="center" ItemStyle-Width="50" Visible="true">
<ItemTemplate>
<asp:LinkButton ID="linkbtnDetail" Runat="server" CommandName="detail">详细 </asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>在后台编辑datagrid 的 ItemCommand事件
用javascript显示新的页面
在數據綁定到DataGrid前就添加超链接,即在從數據庫讀取數據時就加上,這樣就比較簡單,沒有樓上的麻煩!
比如:
String sql="select '<a href=Default.aspx?SCode='+SiteCode+'&ICode='+ItemCode+'>'+Title+'</a>' from Contents where SiteCode='"+SiteCode+"' and ItemCode='"+ItemCode+"'";//<a href>...</a>可根據需要修改連結地址
Content.DataSource=new Sql().GetDataSet(sql).Tables[0];//此處的Sql().GetDataSet()為自定義的一個返回DataSet的方法.Content為DataGrid.
Content.DataBind();
這個是肯定能行的.我就是這樣做的,屢試不爽!!!^_^
HeaderText="文章标题"
DataNavigateUrlField="sn"
DataNavigateUrlFormatString="title_detail.aspx?sn={0}"
DataTextField="title"/>