Reputation: 1615
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
Upvotes: 0
Views: 6400
Reputation: 6302
You can refer to this post How to update an datagrid with webmethods
Upvotes: 1