Hi!
I'm trying to use hyperlink fields in my gridview to pass certain values into another page using querystrings. On the next page I've put 'labels' that should be populated with data from the gridview, however nothing happens. This is my gridview code:
"<asp:GridView ID="GridViewGuitars" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSourceGuitars" DataKeyNames="ProductID" BorderColor="White">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
SortExpression="ProductID" InsertVisible="False" ReadOnly="True"
Visible="False" />
<asp:BoundField DataField="Prod_Name"
SortExpression="Prod_Name" />
<asp:BoundField DataField="Prod_Price"
SortExpression="Prod_Price" />
<asp:BoundField DataField="Prod_Instock" HeaderText="Prod_Instock"
SortExpression="Prod_Instock" Visible="False" />
<asp:BoundField DataField="Prod_Descrip" HeaderText="Prod_Descrip"
SortExpression="Prod_Descrip" Visible="False" />
<asp:ImageField DataImageUrlField="ProductID"
DataImageUrlFormatString="Images/Products/Small/{0}.jpg">
</asp:ImageField>
<asp:HyperLinkField DataNavigateUrlFields="ProductID,Prod_Name,Prod_Price,Prod_Instock,Prod_Descrip"
DataNavigateUrlFormatString="ProdDetails.aspx?ProductID={0}&Prod_Name={1}&Prod_Price={2}&Prod_Instoc k={3}&Prod_Descrip={4}"
Text="More..." />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceGuitars" runat="server"
ConnectionString="<%$ ConnectionStrings:MusicProDataBaseConnectionString %>"
SelectCommand="SELECT ProductID, Prod_Name, Prod_Price, Prod_Instock, Prod_Descrip FROM Products WHERE (Prod_Cat = 'AGuitar') OR (Prod_Cat = 'BGuitar') OR (Prod_Cat = 'EGuitar') OR (Prod_Cat = 'Amp') ORDER BY Prod_Price">
</asp:SqlDataSource>"
And this is the code behind file on the landing page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim ProdID As String = Request.QueryString("ProductID")
Dim ProdName As String = Request.QueryString("Prod_Name")
Dim ProdPrice As String = Request.QueryString("Prod_Price")
Dim ProdStock As String = Request.QueryString("Prod_Instock")
Dim ProdDescrip As String = Request.QueryString("Prod_Descrip")
LabelProdID.Text = ProdID
LabelProdName.Text = ProdName
LabelProdPrice.Text = ProdPrice
LabelProdStock.Text = ProdStock
LabelProdDescrip.Text = ProdDescrip
End Sub
I spent a lot of time trying to find the answer, but with no luck. Please help.
Thanks
I'm trying to use hyperlink fields in my gridview to pass certain values into another page using querystrings. On the next page I've put 'labels' that should be populated with data from the gridview, however nothing happens. This is my gridview code:
"<asp:GridView ID="GridViewGuitars" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSourceGuitars" DataKeyNames="ProductID" BorderColor="White">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
SortExpression="ProductID" InsertVisible="False" ReadOnly="True"
Visible="False" />
<asp:BoundField DataField="Prod_Name"
SortExpression="Prod_Name" />
<asp:BoundField DataField="Prod_Price"
SortExpression="Prod_Price" />
<asp:BoundField DataField="Prod_Instock" HeaderText="Prod_Instock"
SortExpression="Prod_Instock" Visible="False" />
<asp:BoundField DataField="Prod_Descrip" HeaderText="Prod_Descrip"
SortExpression="Prod_Descrip" Visible="False" />
<asp:ImageField DataImageUrlField="ProductID"
DataImageUrlFormatString="Images/Products/Small/{0}.jpg">
</asp:ImageField>
<asp:HyperLinkField DataNavigateUrlFields="ProductID,Prod_Name,Prod_Price,Prod_Instock,Prod_Descrip"
DataNavigateUrlFormatString="ProdDetails.aspx?ProductID={0}&Prod_Name={1}&Prod_Price={2}&Prod_Instoc k={3}&Prod_Descrip={4}"
Text="More..." />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceGuitars" runat="server"
ConnectionString="<%$ ConnectionStrings:MusicProDataBaseConnectionString %>"
SelectCommand="SELECT ProductID, Prod_Name, Prod_Price, Prod_Instock, Prod_Descrip FROM Products WHERE (Prod_Cat = 'AGuitar') OR (Prod_Cat = 'BGuitar') OR (Prod_Cat = 'EGuitar') OR (Prod_Cat = 'Amp') ORDER BY Prod_Price">
</asp:SqlDataSource>"
And this is the code behind file on the landing page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim ProdID As String = Request.QueryString("ProductID")
Dim ProdName As String = Request.QueryString("Prod_Name")
Dim ProdPrice As String = Request.QueryString("Prod_Price")
Dim ProdStock As String = Request.QueryString("Prod_Instock")
Dim ProdDescrip As String = Request.QueryString("Prod_Descrip")
LabelProdID.Text = ProdID
LabelProdName.Text = ProdName
LabelProdPrice.Text = ProdPrice
LabelProdStock.Text = ProdStock
LabelProdDescrip.Text = ProdDescrip
End Sub
I spent a lot of time trying to find the answer, but with no luck. Please help.
Thanks