0

I want to know how , if possible to bind my gridview from javascript in asp.net web forms.

My goal is to click a linkbutton which is in my grid view and it opens up a modalpopup which populates a grid view in that modalpopup.

Hopefully my code snips explain my problem :

aspx:

           <asp:TemplateField ItemStyle-Width="50px" ShowHeader="true" Visible="true">
                <ItemTemplate>
                     <asp:LinkButton ID="lnkSubmitClaim" runat="server" Text='<%# Bind("hypLinkSubmit") %>'></asp:LinkButton>
                </ItemTemplate>
           </asp:TemplateField>

cs: in the "protected void dgEC_RowDataBound(object sender, GridViewRowEventArgs e)" method:

      Claim ec1 = e.Row.DataItem as Claim;
      LinkButton lnkSubmit = (LinkButton)e.Row.FindControl("lnkSubmitClaim");
      lnkSubmit.Attributes.Add("onClick", "return false;");
      lnkSubmit.OnClientClick = String.Format("javascript:ShowPopup({0},{1})", "'" + ec1.GUID + "'", "'" + ec1.Claim_Number + "'");

...

    public string BindClaim(string claimNo)
    {
        dgPopUpClaims.DataSource = service.Get_Claim_Approvals(claimNo);
        dgPopUpClaims.DataBind();
        return "";
    }

js:

    function ShowPopup(guid, claimNo) {
        $find("ModalPopupExtenderClaim").show();
        document.getElementById('<%= hdnGUID.ClientID %>').value = guid;
        document.getElementById('<%= hdnClaimNo.ClientID %>').value = claimNo;
        var bla = document.getElementById('<%= BindClaim() %>');
    }

I retrieve a list of Approval_Item Objects from my webservice...

public class Approval_Item
{
    public string Employee_Number { get; set; }
    public string Employee_Name { get; set; }
}

Can i do this from javascript and update the ajax modalpopup datagrid ?

If not how could i pass the claimNo parameter to the BindClaim() method ?

Hope my question is somewhat understandable, i am new to ajax , so any advice and perhaps resources/links to help further my understanding would be very much appreciated....

Thanking you in advance... Marco

1 Answer 1

1

You can refer to this post How to update an datagrid with webmethods

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

2 Comments

Thanks for the link , will follow it later today and see if it workd , is there no chance i could pass the parameter into the method here : var bla = document.getElementById('<%= BindClaim(claimNo) %>'); ? Think i will need to do some researching and practicing with ajax.... Thanks again for link , will check it out and mark as answer should it solve my issue
Yup do some more research and take some tutorials. Calling BindClaim that way wont do anything really.

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.