0
我的場景是從我的數據庫中獲取故事數據n標題並顯示在gridview現在標題是超鏈接,當用戶點擊任何鏈接時,超鏈接文本發送到閱讀器頁面,故事通過標題文本從數據庫中獲取。我怎麼能這樣做,請幫助我..如何獲取網格視圖中的超鏈接文本並將該文本發送到另一頁
我的場景是從我的數據庫中獲取故事數據n標題並顯示在gridview現在標題是超鏈接,當用戶點擊任何鏈接時,超鏈接文本發送到閱讀器頁面,故事通過標題文本從數據庫中獲取。我怎麼能這樣做,請幫助我..如何獲取網格視圖中的超鏈接文本並將該文本發送到另一頁
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="CustomersGridView_RowDataBound" DataKeyNames="storyid" DataSourceID="yourdatasource">
<Columns>
<asp:BoundField DataField="StoryData" HeaderText="StoryData" InsertVisible="False" ReadOnly="True" SortExpression="StoryData" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
</Columns>
</asp:GridView>
<script runat="server">
void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
HyperLink link = new HyperLink();
link.Text = e.Row.Cells[1].Text.ToString();
link.NavigateUrl = @"ReaderPage.aspx?StoryTitle=" + e.Row.Cells[1].Text.ToString();
link.Attributes.Add("onmouseover", "this.style.backgroundColor='red'");
link.Attributes.Add("onmouseout", "this.style.backgroundColor='#E9EDF1'");
link.Target = "_blank";
e.Row.Cells[1].Controls.Add(link);
}
}
</script>
謝謝你兄弟... –
@WellCome gald它幫助 –
當你點擊任何鏈接,請解釋?? – Rex
你是什麼意思「不工作」? DR1.GetValue(0)的ToString();在調試時有價值嗎?編輯:也str =?當頁面加載? –
你可以粘貼你的代碼gridveiw的答案? –