Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

postback gridview row count to text tag...

Status
Not open for further replies.

VisualGuy

Programmer
May 27, 2003
162
US
I was wondering if anyone knew why when I try and to get a grid view row count, I get 0, unless I call the count from a second button AFTER the gridview has already loaded.
 
You don't want to count the rows in the grid. If you want to display a row count, count the rows in the datasource(datatable, etc) that the grid is binding too.
 
I tried that, but couldn't figure out how to do it...Below, you can see that my datasource is called SqlDataSource1. There isn't a table. How and on what event can I access this information?

<asp:GridView ID="GridView2" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" AlternatingRowStyle-BackColor="#CCFFFF" >
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:ButtonField Text="Expand Details" ButtonType="Button" />
<asp:BoundField DataField="Account_Number" HeaderText="Account_Number"
SortExpression="Account_Number" />
<asp:BoundField DataField="Full_Name" HeaderText="Full_Name"
SortExpression="Full_Name" />
<asp:BoundField DataField="Last_Name" HeaderText="Last_Name"
SortExpression="Last_Name" />
<asp:BoundField DataField="Social_Number" HeaderText="Social_Number"
SortExpression="Social_Number" />
</Columns>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:purgedAccountsConnectionString %>" >
</asp:SqlDataSource>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top