J
Jonathan Wood
Okay, I spent about 3 hours getting the GridView control to do what I
needed.
Basically, I set the control's AutoGenerateColumns to False and then defined
a single template column (which I will customize with my own content). This
looks something like this:
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="100%" AllowPaging="False"
OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Articles">
<ItemTemplate>
<b><%# Eval("art_name") %></b><br />
<%# Eval("art_desc") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then, in my page's Load event, I run a database query and do something like
this:
SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();
I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It looks
fine in the IDE.)
I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.
Does anyone have any ideas?
Thanks!
needed.
Basically, I set the control's AutoGenerateColumns to False and then defined
a single template column (which I will customize with my own content). This
looks something like this:
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="100%" AllowPaging="False"
OnPageIndexChanged="GridView1_PageIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Articles">
<ItemTemplate>
<b><%# Eval("art_name") %></b><br />
<%# Eval("art_desc") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then, in my page's Load event, I run a database query and do something like
this:
SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();
I finally got it working. However, when I set the AllowPaging property to
True, then the grid displays absolutely nothing on the Web page. (It looks
fine in the IDE.)
I even tried running a new query and re-executing the lines above in
response to the control's PageIndexChanged event but that doesn't help.
Does anyone have any ideas?
Thanks!