N
Nathan Sokalski
I have a GridView control with three columns, all BoundField columns. They
all have a HeaderText and DataField property set, and the third one has a
DataFormatString property as well. When I run my code, the GridView displays
two sets of columns. The first set looks exactly as I would expect. The
second set, which should not be there anyway, uses the DataField as the
header and does not apply the DataFormatString for the third column. What is
going on here? Here is my GridView control:
<asp:GridView ID="grdGifts" runat="server" PageSize="15"
PagerSettings-Mode="NextPrevious" PagerSettings-NextPageText="Next 15
Products" PagerSettings-Position="Bottom"
PagerSettings-PreviousPageText="Previous 15 Products"
EnableSortingAndPagingCallbacks="true" AllowPaging="true"
AllowSorting="true">
<Columns>
<asp:BoundField HeaderText="Products" DataField="prodname"/>
<asp:BoundField HeaderText="Brand" DataField="brandname"/>
<asp:BoundField HeaderText="Action" DataField="prodid"
DataFormatString="[ <a
href='edit_product.asp?prodid={0}'>Edit</a> / <a
href='delete_product.asp?prodid={0}'>Delete</a> ]"/>
</Columns>
</asp:GridView>
The Load event for the GridView is as follows:
Private Sub grdGifts_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles grdGifts.Load
Dim myconnection As New
SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
Dim gifts As New DataTable
Dim giftadapter As New SqlDataAdapter("SELECT
products.prodname,brands.brandname,products.prodid FROM products INNER JOIN
brands ON prodbrand=brandid", myconnection)
giftadapter.Fill(gifts)
Me.grdGifts.DataSource = gifts
Me.grdGifts.DataBind()
End Sub
If anybody has any idea why this is happening, I would appreciate the help.
Thanks.
all have a HeaderText and DataField property set, and the third one has a
DataFormatString property as well. When I run my code, the GridView displays
two sets of columns. The first set looks exactly as I would expect. The
second set, which should not be there anyway, uses the DataField as the
header and does not apply the DataFormatString for the third column. What is
going on here? Here is my GridView control:
<asp:GridView ID="grdGifts" runat="server" PageSize="15"
PagerSettings-Mode="NextPrevious" PagerSettings-NextPageText="Next 15
Products" PagerSettings-Position="Bottom"
PagerSettings-PreviousPageText="Previous 15 Products"
EnableSortingAndPagingCallbacks="true" AllowPaging="true"
AllowSorting="true">
<Columns>
<asp:BoundField HeaderText="Products" DataField="prodname"/>
<asp:BoundField HeaderText="Brand" DataField="brandname"/>
<asp:BoundField HeaderText="Action" DataField="prodid"
DataFormatString="[ <a
href='edit_product.asp?prodid={0}'>Edit</a> / <a
href='delete_product.asp?prodid={0}'>Delete</a> ]"/>
</Columns>
</asp:GridView>
The Load event for the GridView is as follows:
Private Sub grdGifts_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles grdGifts.Load
Dim myconnection As New
SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connectionstring"))
Dim gifts As New DataTable
Dim giftadapter As New SqlDataAdapter("SELECT
products.prodname,brands.brandname,products.prodid FROM products INNER JOIN
brands ON prodbrand=brandid", myconnection)
giftadapter.Fill(gifts)
Me.grdGifts.DataSource = gifts
Me.grdGifts.DataBind()
End Sub
If anybody has any idea why this is happening, I would appreciate the help.
Thanks.