Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:56:03+00:00 2026-05-26T09:56:03+00:00

Im trying to get the userID out of my database put it into a

  • 0

Im trying to get the userID out of my database put it into a DetailsView and get the value and set it to a label.

Im getting an error that the the string is empty.

public void SendButton_Click(object sender, EventArgs e)
{
    labelID.Text = DetailsView1.Rows[0].Cells[1].Text;
    strVariable = labelID.Text;

    System.Diagnostics.Debug.Write("variabelen: " + strVariable);
    System.Guid g =  new Guid(strVariable);
    SqlDataSource1.InsertParameters[3].DefaultValue = g.ToString();
    SqlDataSource1.Insert();
}


<asp:Label ID="labelID"  Name="LabelID" runat="server"></asp:Label>

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
    DataSourceID="SqlDataSource2" Height="50px" Width="125px" 
    DefaultMode="Edit">
    <Fields>
        <asp:BoundField DataField="UserId" HeaderText="UserId" 
            SortExpression="UserId" />
    </Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    SelectCommand="SELECT UserId FROM aspnet_Users WHERE (UserName = 'bo')">

</asp:SqlDataSource>

Note that the labelID.Text is in a click button event and that the Detailview (grid) loading is when the user is logged in. The user id get’s loaded in detailsview1 when the user is logged in.

How can i fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:56:04+00:00Added an answer on May 26, 2026 at 9:56 am

    It’s hard to say exactly what the problem is without more context, but I would assume that DetailsView1.Rows[0].Cells[1].Text is not the proper location within the DetailsView to look for the user id. You could try setting a breakpoint on that line in Visual Studio and stepping through the rows and cells in the immediate window to find the proper location.

    If you could provide the code you use as the data source for the DetailsView as well as the definition of the DetailsView that would be helpful.

    EDIT BASED ON NEW SAMPLE CODE:

    When I run your sample code, ( DetailsView1.Rows[0].Cells[1].Controls[0] as TextBox ).Text gives me the user id value. You have to go into the Controls collection on Cells[1] as the DetailsView renders the bound fields as TextBoxes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get a random string out of ListArray on the button pressed. Always
I'm trying to figure out how I can insert a NULL value into a
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using
trying to get same string on tooltip as is in the Text e.g. Text=<%#
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I am just trying to figure out how Facebook's database is structured for tracking
I am trying to figure out how to layout my database for a site
I have a problem trying to get the count out of the following query:
I'm trying to figure out how to store a hash in my Access Database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.