Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASp.Net DataGrid

ASp.Net DataGrid

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
13 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Minuab
    wrote on last edited by
    #1

    I want to check the value entered in a row, so i can use it for other purpose.Is there any events that fire when a row is being edited. I tried the textchange event of the textbox in the row, but its not working. For eg: In a Qty column in datagrid, a user can enter maximum of 25. So if the user exceeds 25, display message to user that it is exceeded. Also show details where all the Qty is being entered. MA

    _ S 2 Replies Last reply
    0
    • M Minuab

      I want to check the value entered in a row, so i can use it for other purpose.Is there any events that fire when a row is being edited. I tried the textchange event of the textbox in the row, but its not working. For eg: In a Qty column in datagrid, a user can enter maximum of 25. So if the user exceeds 25, display message to user that it is exceeded. Also show details where all the Qty is being entered. MA

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      Hi, You can use javascript to check for the maximum length of the textbox. Best Regards, Apurva Kaushal

      M 1 Reply Last reply
      0
      • _ _AK_

        Hi, You can use javascript to check for the maximum length of the textbox. Best Regards, Apurva Kaushal

        M Offline
        M Offline
        Minuab
        wrote on last edited by
        #3

        I want to fire the event for each row. how is it possible.On editing a particular row, the event has to be fired and based on the value entered,it has to check from database if the value is exceeded. how to use javascript.

        _ 1 Reply Last reply
        0
        • M Minuab

          I want to fire the event for each row. how is it possible.On editing a particular row, the event has to be fired and based on the value entered,it has to check from database if the value is exceeded. how to use javascript.

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          Hi, Onitemdatabound event fires for all the row of the datagrid. And while updating the row you can to validate something from the database. Best Regards, Apurva Kaushal

          R 1 Reply Last reply
          0
          • _ _AK_

            Hi, Onitemdatabound event fires for all the row of the datagrid. And while updating the row you can to validate something from the database. Best Regards, Apurva Kaushal

            R Offline
            R Offline
            RSArockiam
            wrote on last edited by
            #5

            set maxlength property of the textbox, which will not accept more characters than the maximum characters allowed into the textbox. It is very simple solution. Regards R.Arockiapathinathan

            1 Reply Last reply
            0
            • M Minuab

              I want to check the value entered in a row, so i can use it for other purpose.Is there any events that fire when a row is being edited. I tried the textchange event of the textbox in the row, but its not working. For eg: In a Qty column in datagrid, a user can enter maximum of 25. So if the user exceeds 25, display message to user that it is exceeded. Also show details where all the Qty is being entered. MA

              S Offline
              S Offline
              swapnilbhavsar
              wrote on last edited by
              #6

              Hi u can solve this problem by adding one javascript function in the textbox. In that,u just send the id of each text boxes and in that javascript function, u have check the length of that text box by finding text box as getelementbyid. Swapnil Bhavsar

              M 1 Reply Last reply
              0
              • S swapnilbhavsar

                Hi u can solve this problem by adding one javascript function in the textbox. In that,u just send the id of each text boxes and in that javascript function, u have check the length of that text box by finding text box as getelementbyid. Swapnil Bhavsar

                M Offline
                M Offline
                Minuab
                wrote on last edited by
                #7

                Datagrid's ItemdataBound gets fired only when page goes to server. But while editing datagrid(many rows) with 1 Update Button, on going from one row to another which event is fired. For eg: If there is Qty column if i enter some value and goes to next row,i want to do validation. Instead of validating all rows together.

                R 1 Reply Last reply
                0
                • M Minuab

                  Datagrid's ItemdataBound gets fired only when page goes to server. But while editing datagrid(many rows) with 1 Update Button, on going from one row to another which event is fired. For eg: If there is Qty column if i enter some value and goes to next row,i want to do validation. Instead of validating all rows together.

                  R Offline
                  R Offline
                  RSArockiam
                  wrote on last edited by
                  #8

                  what kinf of validation? If you want to client side validation then you can do using javascript. But if you want to server side then you can try the following: HTML ==== <asp:TextBox ID="TextBox1" runat="server" AutoPostBack=true OnTextChanged="TextBox1_TextChanged"> CodeBehind =========== protected void TextBox1_TextChanged(object sender, EventArgs e) { Response.Write("Textbox value changed"); } This event is executing (it should postback to server) correctly for me when the textbox text is changed. Regards R.Arockiapathinathan

                  M 1 Reply Last reply
                  0
                  • R RSArockiam

                    what kinf of validation? If you want to client side validation then you can do using javascript. But if you want to server side then you can try the following: HTML ==== <asp:TextBox ID="TextBox1" runat="server" AutoPostBack=true OnTextChanged="TextBox1_TextChanged"> CodeBehind =========== protected void TextBox1_TextChanged(object sender, EventArgs e) { Response.Write("Textbox value changed"); } This event is executing (it should postback to server) correctly for me when the textbox text is changed. Regards R.Arockiapathinathan

                    M Offline
                    M Offline
                    Minuab
                    wrote on last edited by
                    #9

                    I am using a datagrid with template columns. Column is made as textbox for editing. So when we edit column and lost focus from that row, what event will fire. I tried the ontextchange event of the column textbox, but it doesn't work. In windows forms there currentcellchange event which fires when we losts focus from a particular cell. Is there any event that can be used in this case. I have been serching for this for long time. I have a Save button outside for saving all rows in grid. But if i write anything on Saving, it will work last after editing all rows. I want the event to be fired after editing a particular row. hope U understood my explanation.

                    _ 1 Reply Last reply
                    0
                    • M Minuab

                      I am using a datagrid with template columns. Column is made as textbox for editing. So when we edit column and lost focus from that row, what event will fire. I tried the ontextchange event of the column textbox, but it doesn't work. In windows forms there currentcellchange event which fires when we losts focus from a particular cell. Is there any event that can be used in this case. I have been serching for this for long time. I have a Save button outside for saving all rows in grid. But if i write anything on Saving, it will work last after editing all rows. I want the event to be fired after editing a particular row. hope U understood my explanation.

                      _ Offline
                      _ Offline
                      _AK_
                      wrote on last edited by
                      #10

                      Hi, As far as i have have understood the problem you need to do some operation on lost focus of the textbox in the datagrid. In that case if you want client side operation then you can use javascript for that or else you can go for TextBox_TextChanged event, but be sure to make autopostback property of the textbox to true. Hope this may help you. Best Regards, Apurva Kaushal

                      M 1 Reply Last reply
                      0
                      • _ _AK_

                        Hi, As far as i have have understood the problem you need to do some operation on lost focus of the textbox in the datagrid. In that case if you want client side operation then you can use javascript for that or else you can go for TextBox_TextChanged event, but be sure to make autopostback property of the textbox to true. Hope this may help you. Best Regards, Apurva Kaushal

                        M Offline
                        M Offline
                        Minuab
                        wrote on last edited by
                        #11

                        Thanks Apurva, I didnt made to the autopostback to true, thats why it was not firing. Can u help in getting the column value of the edited row in Datagrid. For eg: I edit a textbox column in datagrid, when i lost focus from the cell,ontextchange event of textbox is fired. How to get the column values of the edited Row. I tried using Datagrid1.findcontrol("field"), but its not working.

                        _ 1 Reply Last reply
                        0
                        • M Minuab

                          Thanks Apurva, I didnt made to the autopostback to true, thats why it was not firing. Can u help in getting the column value of the edited row in Datagrid. For eg: I edit a textbox column in datagrid, when i lost focus from the cell,ontextchange event of textbox is fired. How to get the column values of the edited Row. I tried using Datagrid1.findcontrol("field"), but its not working.

                          _ Offline
                          _ Offline
                          _AK_
                          wrote on last edited by
                          #12

                          Hi, Directly you wont be able to find the control. So try to find out in items of the datagrid. Something like this: Label lll = (Label)DataGrid1.Items[i].FindControl("Label1"); Hope this will help you. Best Regards, Apurva Kaushal

                          M 1 Reply Last reply
                          0
                          • _ _AK_

                            Hi, Directly you wont be able to find the control. So try to find out in items of the datagrid. Something like this: Label lll = (Label)DataGrid1.Items[i].FindControl("Label1"); Hope this will help you. Best Regards, Apurva Kaushal

                            M Offline
                            M Offline
                            Minuab
                            wrote on last edited by
                            #13

                            I tried like this Dim xmonth As Label = DataGrid1.Items(3).FindControl("PMonth") here i will get the value of the 3rd row. Is it possible to get the value of the row in which the column was edited. For Items(i), how to pass the edited row. I have written code on the textchange of a column in datagrid, how to get the row being edited. regards, MinuA

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups