I have a select query that list out the Computer brand and the price.
what I want is that when I click on the computer brand then the respective information about this brand will be display in the same page or open a new page. I am using a datagrid, how do I make this work? or should I use other component like table.
Please helpIf you have unique Identifier for the Computerband table use it to create a hyperlink column in the datagrid. then pass the id as querystring. During the postback event read the Id get the details of the brand form from the id and then you can display that in formation in a panel below this grid.
Note;
1. AutoGenerateColumns property must be set to False
2. Manually Create DataGrid columns including the hyperlink column
Ex:
<asp:DataGrid id="dg1" AutoGenerateColumns="False" runat="server">
<asp:HyperLinkColumn Headertext="Brand Id" DataTextField="BrandId" DataNavigationUrlField="BrandId" DataNavigationUrlFormatString="ComputerBrands.aspx?brandId={0}" />
<asp:BoundColumn DataField="ComputerBrandName" HeaderText="Brand Name"/>
<!-- .... add other columns -->
</asp:DataGrid
Thanks
Thank you Jay.
I still have som problem, I create a procedure that reads
Create Proc GetComputerID
@.ComputerID int
as
Select Computer,Price,CPU from Computers
Where ComputerID = @.ComputerID
I do not know where to pass the parameter in the grid, and I could not type computerID={0}
vb.net would not even allow me to run the application
I removed the where claus from my statement. But when I click on the hyperlink, nothing happens.
Here is the ASP code:
<asp:HyperLinkColumn Text="Computer" Target="_self" DataNavigateUrlField="ComputerID" DataNavigateUrlFormatString="UsedComputer.aspx?ComputerId={0}"
DataTextField="Computer" HeaderText="Computer" NavigateUrl="Computer"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="Price" HeaderText="Price"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="ComputerID" HeaderText="ComputerID"></asp:BoundColumn>
</Columns>
0 comments:
Post a Comment