Link to home
Start Free TrialLog in
Avatar of SullivanMIS
SullivanMIS

asked on

Visual Studio 2008 asp vb code: Binding SQLDatasource output to gridview with Textboxes

I am having a slight bit of trouble getting my output to show up as I would like. Please take a look at this snippet. As always, I have tried to dumb down the example as much as possible, changing variable names what not so this is a basic example that is hopefully easy to read and understand:

<asp:SqlDataSource ID="SqlDataSourceNames" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" EnableViewState="False"  

SelectCommand="SELECT DISTINCT table1.ForName, table1.Counts FROM table1 LEFT OUTER JOIN table2 on table1.1 = table2.1 WHERE (table2.3 = @my3) AND (table2.4 = @my4) AND (table2.5 = @my5) AND (table2.6 = @my6)">
<SelectParameters>
<asp:SessionParameter Name="my3" SessionField="Sess3" />
<asp:SessionParameter Name="my4" SessionField="Sess4" />
<asp:SessionParameter Name="my5" SessionField="Sess5" />
<asp:SessionParameter Name="my6" SessionField="Sess6" />
</SelectParameters>
</asp:SqlDataSource>
                                                                                
                                                                                
                                                                                
<asp:GridView ID="GridViewMyList" runat="server" BorderStyle="None" BorderWidth="0px" CellSpacing="5" DataSourceID="SqlDataSourceNames" EnableViewState="False" ShowFooter="True">
<Columns>
      <asp:TemplateField HeaderText="Count Num:">
          <ItemTemplate>
               <asp:TextBox ID="TextBox0" runat="server" Columns="3" Text='<%# Bind("Counts") %>'></asp:TextBox>
          </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="My List of Names:">
          <ItemTemplate>
               <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ForName") %>'></asp:TextBox>
          </ItemTemplate>
          <FooterStyle HorizontalAlign="left" />
              <FooterTemplate>
                   <asp:Button ID="ButtonUpdateCounts" runat="server" Text="Update Counts" />
              </FooterTemplate>
          </asp:TemplateField>
   </Columns>
</asp:GridView>

Open in new window




What I intend to end up with is two columns, each with textboxes containing the data from the two fields coming out of the sqldatasource query. There would also be a footer at the bottom with a button to update the counts...

Count Num: | My List of Names: |
[__3__]                   [___Tom___]            
[__4__]                   [___John___]            
[__2__]                   [___Steve___]          

                             [__Update Counts__]



What I am ACTUALLY getting is four columns. Two show up the way I want them to in text boxes, but I also get two columns as text only with the names and counts....

Count Num: | My List of Names: | ForName | Counts
[__3__]                   [___Tom___]            Tom              3
[__4__]                   [___John___]            John              4
[__2__]                   [___Steve___]          Steve             2

                             [__Update Counts__]

Clearly, some minor detail in how I am setting up the code is going to make the difference for me, but I have not identified what needs to be changed. Any help would be appreciated and expert points are waiting to be awarded.
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SullivanMIS
SullivanMIS

ASKER

Well that was easy...

AutoGenerateColumns = "False" solved my problem