ASp.Net DataGrid
-
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
-
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
-
Hi, You can use javascript to check for the maximum length of the textbox. Best Regards, Apurva Kaushal
-
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.
-
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
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
-
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
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
-
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
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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.
-
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.
-
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 KaushalI 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