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

  • Home
  • SEARCH
  • 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 3483984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:44:13+00:00 2026-05-18T10:44:13+00:00

i want to Capture the the Text Entered by a user when the update

  • 0

i want to Capture the the Text Entered by a user when the update Command is Pressed taking into Consideration that i Changed the Edit and Update Command To be named Activate

 <asp:DataGrid ID="Datagrid1" runat="server" AutoGenerateColumns="False" Width="100%"
    OnCancelCommand="Datagrid1_CancelCommand" OnEditCommand="Datagrid1_EditCommand"
    OnUpdateCommand="Datagrid1_UpdateCommand">
    <Columns>
        <asp:TemplateColumn>
              <EditItemTemplate>
                <table cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td align="center" style="width: 200px; white-space: nowrap;">
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Reg_FullName") %>'></asp:Label>
                        </td>
                        <td align="center" style="width: 100px;">
                            <asp:Label ID="lbl_User" runat="server" Text='<%# Eval("Reg_UserName") %>'></asp:Label>
                        </td>
                        <td align="center" style="width: 100px;">
                            <asp:Label ID="lbl_AddedAt" runat="server" Text='<%# Eval("Reg_ActivatedAt") %>'></asp:Label>
                        </td>
                        <td align="center" style="width: 100px;">
                            <asp:Label ID="lbl_IsAct" runat="server" Text='<%# Eval("Reg_IsActive") %>'></asp:Label>
                        </td>
                        <td align="center" style="width: 100px;">
                            <asp:Label ID="lbl_Days" runat="server" Text="<%$ Resources:Okaz, DaysNum %>"></asp:Label>
                        </td>
                        <td align="center" style="width: 100px;">
                            <asp:TextBox ID="Hello_txt" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </EditItemTemplate></asp:TemplateColumn>
        <asp:EditCommandColumn CancelText="Cancel" EditText="Activate"
            UpdateText="Activate"></asp:EditCommandColumn>

Well and my code behind is :

protected void Datagrid1_EditCommand(object source, DataGridCommandEventArgs e)
    {
        Datagrid1.EditItemIndex = e.Item.ItemIndex;
        try
        {
            SqlDataSource1.SelectCommand = "Select * from OkazRegisteration";
            Datagrid1.DataSourceID = SqlDataSource1.ID;
            Datagrid1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }

    protected void Datagrid1_CancelCommand(object source, DataGridCommandEventArgs e)
    {
        Datagrid1.EditItemIndex = -1;
        try
        {
            SqlDataSource1.SelectCommand = "Select * from OkazRegisteration";
            Datagrid1.DataSourceID = SqlDataSource1.ID;
            Datagrid1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }

    protected void Datagrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
    {

        switch (e.Item.ItemType)
        {
            case ListItemType.EditItem:

                TextBox txt_Days = (TextBox)e.Item.FindControl("Hello_txt");
                Label lbl_User = (Label)e.Item.FindControl("lbl_User");

                SqlDataSource2.UpdateCommand = "Update OkazRegisteration set Reg_IsActive='True', Reg_ExpiryDays=" + txt_Days.Text + " , Reg_ActivatedAt='" + DateTime.Now.ToShortDateString() + "' Where Reg_UserName='" + lbl_User.Text + "'";
                SqlDataSource2.Update();
                break;
        }
        try
        {
            SqlDataSource1.SelectCommand = "Select * from OkazRegisteration";
            Datagrid1.DataSourceID = SqlDataSource1.ID;
            Datagrid1.DataBind();
        }
        catch (Exception ex)
        {
            ErrorLabel.Text = ex.ToString();
        }
    }

in the Datagrid1_UpdateCommand

The Text Value of the TextBox txt_Days is always empty

What am i doing wrong ??

I’ve done this kind of work for a really long time , but i cannot see the error this time

Please Help,

Regards.

  • 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-18T10:44:14+00:00Added an answer on May 18, 2026 at 10:44 am

    I found out that I am binding my grid every time the page loads so that the text inside my text box is erased.

    Hope that gives a hint to anyone faces the same issue

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

Sidebar

Related Questions

I want to capture when a user pastes data into a text input field
I want to capture text in an attribute within an XML tag. That is
I want to capture the HTTP request header fields, primarily the Referer and User-Agent,
I want to capture the errors from a script into a file instead of
I want to capture the responseXML that i have built in my jsp. What
I'm using jQuery to alter things when a user enters text into an input.
Say I have a long string of text, and I want to capture every
I want to capture the text within the square brackets in the html string
i want to capture all tags named 'STRONG' i can use <STRONG.*?</STRONG> this is
I have a JFace SourceViewer that I'm modifying and I want to capture when

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.