第一次在第二次点击时加载数据不会在按钮中加载 [英] Data is not loaded in button first time it will be loaded on second click
问题描述
在运行页面中如下
链接按钮如下
查看选定的课程详情
当我点击查看所选课程详情时,弹出窗口将显示。
在弹出窗口中,我有一个名为View Batch date of selected course details的按钮。
当我点击所选课程详情的查看批日期时。
在Gridview中显示详细信息。
假设我再次单击查看所选课程详细信息的另一个课程链接按钮
弹出窗口将显示。
当我点击弹出的前一课程详细信息将在gridview中删除。
我该怎么办。
我的Gridview代码如下
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
尝试使用(var con = new SqlConnection(ConfigurationManager.ConnectionStrings [" himtConnectionString"]。ConnectionString))
{
using(var cmd = new SqlCommand(OH_PKG_DATE_COMBINATION'+ Session [compkgid]。ToString()。Trim()+',con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
in run page as follows
Link button as follows
View Selected Course Details
When i click the View Selected Course Details popup will be shown.
In pop up i have one button called View Batch date of selected course details.
When i click the View Batch date of selected course details.
In Gridview details are shown.
Suppose again i click View Selected course details of another course of link button
Pop up will be shown .
when i click the pop up previous course details to be removed in gridview.
for that how can i do.
My Gridview code as follows
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["himtConnectionString"].ConnectionString))
{
using (var cmd = new SqlCommand("OH_PKG_DATE_COMBINATION '" + Session["compkgid"].ToString().Trim() + "'", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
推荐答案
删除if (!IsPostBack)
签入代码,然后它将在点击事件中加载新数据
remove if (!IsPostBack)
check in your code, then it will load new data in click event
这篇关于第一次在第二次点击时加载数据不会在按钮中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!