gpt4 book ai didi

javascript - 在加载 asp.net 网格后调用 Jquery 函数

转载 作者:太空宇宙 更新时间:2023-11-03 23:43:28 27 4
gpt4 key购买 nike

一旦显示 ASP.Net GridView,我想调用一个 jQuery 函数。我已经尝试过就绪/加载功能,但对我来说没有用。

网格在更新面板内

<asp:GridView ID="grdNumberPlan" runat="server" 
CssClass="table table-condensed table-hover table-striped rt"
Visible="false">
</asp:GridView>
$('#<%=grdNumberPlan.ClientID%>').ready(function () {
alert('hello');
});

$('#<%=grdNumberPlan.ClientID%>').load(function () {
alert('hello');
});

aspx.cs代码

protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
{
try
{

if (ddlHLR.SelectedValue == "0")
{
((UIMaster)Page.Master).SetMessage(MessageType.Warnining, "Kindly select HLR");
grdNumberPlan.DataSource = null;
grdNumberPlan.DataBind();
rowNewRanges.Visible = false;
grdNumberPlan.Visible = false;
return;
}

if (ddlCity.SelectedValue == "0")
{
((UIMaster)Page.Master).SetMessage(MessageType.Warnining, "Select the city");
grdNumberPlan.DataSource = null;
grdNumberPlan.DataBind();
rowNumPlanSum.Visible = false;
grdNumberPlan.Visible = false;
return;
}

//rangeList();

NumberingPlan objNumberingPlan = new NumberingPlan();
objNumberingPlan.CityID = Convert.ToInt32(ddlCity.SelectedValue);
objNumberingPlan.HlrID = Convert.ToInt32(ddlHLR.SelectedValue);
objNumberingPlan.ExclusiveType = Convert.ToInt32(ddlIssuanceType.IsExclusive.ToString());
objNumberingPlan.Operation_Type = OperationType.Get;

InventoryManagementServiceClient client = new InventoryManagementServiceClient();

DataTable dt = new DataTable();
dt = client.GetNumberingPlanRanges(objNumberingPlan).Tables[0];
grdNumberPlan.Visible = true;
rowNumPlanSum.Visible = true;
grdNumberPlan.DataSource = dt;
grdNumberPlan.DataBind();

///Fill NDC dropdown list
///
NDC objNDC = new NDC();
objNDC.HLRID = Convert.ToInt32(ddlHLR.SelectedValue);
objNDC.CityID = Convert.ToInt32(ddlCity.SelectedValue);
objNDC.Operation_Type = OperationType.Get;

DataTable dtNDC = new DataTable();
serviceClient = new CommonServiceClient();
dtNDC = serviceClient.GetNDC(objNDC).Tables[0];
//GlobalMethods.FillDropDownList(dtNDC, ddlNDC, "NDC", "NDC_ID");
GlobalMethods.FillDropDownList(dtNDC, ddlNDC, "NDC", "NDC");

ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:fnPopUp();", true);

}
catch (Exception ex)
{
((UIMaster)Page.Master).SetMessage(MessageType.Error, ex.Message);
}
}

最佳答案

$(document).ready(function(){
callYourFunction();
});

或者在 gridview 绑定(bind)之后从代码隐藏调用 javascript 函数

grdNumberPlan.DataSource=yourDataTable;
grdNumberPlan.DataBind();
ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:FUNCTIONNAME(); ", true);

关于javascript - 在加载 asp.net 网格后调用 Jquery 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28295666/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com