We help IT Professionals succeed at work.

vb.net, web page, SQL holding the selected data in an accessible variable

163 Views
Last Modified: 2017-04-13
The following code works, but I did not like because in order to get selected sql data I have to add a gridview control!!
Is there a way to get the returned data in a variable

         <asp:SqlDataSource ID="sourcename" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>">            
         </asp:SqlDataSource>
         <%  
             sourcename.SelectParameters.Add("CustIdIs", Session("CustIdIs"))
             sourcename.SelectCommand = "SELECT Col1, col2 FROM Table WHERE Col0= @CustIdIs  "
          %>
         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sourcename">
             <Columns>
                 <asp:BoundField DataField="Col1" HeaderText="Txt1" SortExpression="ttt" />                
                 <asp:BoundField DataField="Col2" HeaderText="Txt2" SortExpression="ttt" />                
            </Columns>
         </asp:GridView>
<%
            Dim I
            Dim str As String

            For I = 1 To GridView1.Rows.Count - 1
                str = GridView1.Rows(I).Cells(0).Text
                Response.Write(str & "<br>")
           Next
Comment
Watch Question

Nitin SontakkeDeveloper
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Prakash SamariyaIT Professional
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Prakash SamariyaIT Professional
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
could not find a solution

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions