0

I have this GridView in my Asp.net application

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True">
        <Columns>
            <asp:TemplateField >
                <ItemTemplate>
                    <asp:Button ID="Savebtn" runat="server" Text="تحديث البيانات"  OnClick="gv_RowEditing"/>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="السعر الأقصى">
                <ItemTemplate>
                    <asp:TextBox ID="maxtxt" runat="server" Text='<%#Eval("prix max")%>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="السعر الأدنى"  >
                <ItemTemplate>
                    <asp:TextBox ID="mintxt" runat="server"  Text='<%#Eval("prix min")%>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Datvente" HeaderText="التاريخ" SortExpression="Datvente" />
            <asp:BoundField DataField="NomAdh" HeaderText="الإسم و اللقب" SortExpression="NomAdh" />
            <asp:BoundField DataField="CodAdh" HeaderText="المنخرط" SortExpression="CodAdh" />

             <asp:TemplateField >
                <ItemTemplate>

                    <asp:HiddenField ID="Ref" runat="server"  Value='<%#Eval("Ref")%>'/>
                </ItemTemplate>
            </asp:TemplateField>


        </Columns>
    </asp:GridView>

Each row contains a submit button to update it.it works but i need to add an ajax function that verify if the row is modified or not . if the case when the user modify the values of a row and forgot to submit the changes the row change its color to red for example.

  1. What is the best idea to do this?
  2. how can i change my code to add this feature?

1 Answer 1

1

1- Create webservice to Call you server side:

[WebMethod]
public string RowEditing(string firstName, string lastName) // your paramenter
{
     //       your code here 
     return "";
}

2- add javascipt function :

function grEdit(){
   // do some script here 
   $.ajax({
      type: "POST",
      url: "MyWebService.asmx/RowEditing",
      data: "firstName=Aidy&lastName=F", // the data and parameter
      dataType: "text",
      success: function (data) {
       // action when succ
      }
   });
 }

3- call inside grid :

< asp:Button ID="Savebtn" runat="server" Text="تحديث البيانات" OnClick="grEdit(); return false;"/>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.