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 8431475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:51:56+00:00 2026-06-10T05:51:56+00:00

I have the following SqlDataSource <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:orangefreshConnectionString1 %> InsertCommand=INSERT INTO [Chat]

  • 0

I have the following SqlDataSource

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:orangefreshConnectionString1 %>" 
        InsertCommand="INSERT INTO [Chat] ([Username], [Message]) VALUES (@Username, @Message)" 
        SelectCommand="SELECT [Id], [Username], [Message], [Date] FROM [Chat] ORDER BY [Id]" >
        <InsertParameters>
            <asp:Parameter Name="Message" Type="String" />
            <asp:Parameter Name="Date" Type="DateTime" /> 
            <asp:Parameter Name="Username" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

Which controls the following FormView:

<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert"
        OnItemInserted="fv_ItemInserted" RenderOuterTable="False" 
            DataSourceID="SqlDataSource1">
        <InsertItemTemplate>
            <asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
            <asp:TextBox ID="TextBox1" runat="server" CssClass="chattxtbox"
            Text='<%# Bind("Message") %>' autocomplete="off"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" CommandName="insert" style="display:none" Text="Button" OnClick="insertUser"/>
            </asp:Panel>
        </InsertItemTemplate>
        </asp:FormView>

I want to be able a variable’s content into the Username column, so on Button1 I set the following event: OnClick=”insertUser”

 protected void insertUser(object sender, EventArgs e)
    {
        string username1 = User.Identity.Name;
        SqlDataSource1.InsertParameters.Add("Username", username1);
        SqlDataSource1.Insert();
    }

This isn’t working though, I don’t get any SQL error message at all, is this the right way to do this? And where did I go wrong?

  • 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-06-10T05:51:57+00:00Added an answer on June 10, 2026 at 5:51 am

    Change Insert Parameter to SessionParameter.

    <InsertParameters>
       <asp:Parameter Name="Message" Type="String" />
       <asp:Parameter Name="Date" Type="DateTime" /> 
       <asp:Parameter Name="Username" Type="String" />
       <asp:SessionParameter Name="Username" SessionField="Username" Type="String" />
    </InsertParameters>
    

    And in Page_Load handler,

    Session["Username"]=User.Identity.Name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQLDataSource : <asp:SqlDataSource ID=topicSource runat=server ConnectionString=<%$ ConnectionStrings SelectCommandType=Text SelectCommand=SELECT *
I have a SqlDataSource SelectCommand on my .aspx page. <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MyConnectionString
I have following code <asp:SqlDataSource ID=SqlDataSource1 runat=server UpdateCommand=UPDATE [gMeter] SET ... [userId] = @userId
I have the following Repeater on my page: <asp:Repeater ID=Repeater1 runat=server DataSourceID=SqlDataSource1 onitemcommand=Repeater1_ItemCommand> <ItemTemplate>
I have the following itemTemplate in my datalist <ItemTemplate> <asp:LinkButton ID=LinkButton1 CommandName=Select autopostback=True runat=server>'<%#
I have defined a nested grid view in the following way. <asp:GridView ID=GridView1 runat=server
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster
On an ASP.NET page, I have a SqlDataSource configured with the following SELECT command:
Hy guys, my question is: if i have in asp.net, a SqlDatasource or AccessDatasource
I have following tables (CustomerType, Customer and Company) in a data base: In asp.net,

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.