如何在页面加载的第一行gridview.rowcommand [英] How to gridview.rowcommand for the first row on page load

查看:88
本文介绍了如何在页面加载的第一行gridview.rowcommand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的

我的方案是当我在行命令下的gridview中单击链接按钮时。选择第一行并执行进一步的工作。我想在绑定网格后在页面加载时执行相同操作。如何使用asp.net在页面加载时为第一行调用row命令。



我的代码在这里

 尝试 
{
if (e.CommandName == do
{
GridViewRow row =(GridViewRow)(((LinkBut​​ton)e.CommandSource).NamingContainer) ;
会话[ reg_no] =((HiddenField)row.FindControl( hidRegNo))。值;
string CS_FLAG =((HiddenField)row.FindControl( hid_Flag))值。
会话[ CS_IS_HANDLE] =((HiddenField)row.FindControl( hid_IsHandle))。值;
if (CS_FLAG == Y
{
this .lnk_Enlarge.Visible = false ;
Panel_Disable();
lblStatus.Text = 此帐户已被锁定并已移至主管;
ModalPopupExtender.Show();
}
else
{
会话[ Loan_acct] =((HiddenField)row.FindControl( hidLoanNo))值。
会话[ Cycle_cut] =((HiddenField)row.FindControl( hidCycleCut))。值;
会话[ Bucket_Code] =((HiddenField)row.FindControl( hidBucketCode))。值;
会话[ 模块] =((HiddenField)row.FindControl( hid_Mod))。值;
会话[ 产品] =((HiddenField)row.FindControl( hid_Prod))。值;
会话[ 城市] =((HiddenField)row.FindControl( hid_City))。值;
会话[ Billing_Cycle] =((HiddenField)row.FindControl( hid_BillingCycle))。值;
.Tabs.Visible = true ;
this .pnl_ActLog.Visible = true ;
ShowFinancial();
ShowSituationSummary();
Show_PIL_Overdue();
ShowActivity();
ShowAppInfo();
ShowDelinquencyHistory();
ShowSchedule();
ShowContacts();
Show_Diary();
Load_All();
Show_Actions();
Show_DiaryNote();
重置();
}
}
lbl_Status.Text = ;
}
catch (例外情况)
{
throw new 异常( 应用程序错误: + ex.Message);
}

解决方案

如果你要做的就是选择第一个gridview行进行编辑页面加载,尝试在调用网格的DataBind()方法之前设置gridview的EditIndex属性。像这样...

 GridView1.EditIndex =  0 ; 


Dear
My scenario is when i click on link button in a gridview under row command.First row selected and perform further work.I want to do the same at page load after grid is binded.How could i call row command for the first row at page load using asp.net.

My Code is here

try
       {
           if (e.CommandName == "do")
           {
               GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
               Session["reg_no"] = ((HiddenField)row.FindControl("hidRegNo")).Value;
               string CS_FLAG = ((HiddenField)row.FindControl("hid_Flag")).Value;
               Session["CS_IS_HANDLE"] = ((HiddenField)row.FindControl("hid_IsHandle")).Value;
               if (CS_FLAG == "Y")
               {
                   this.lnk_Enlarge.Visible = false;
                   Panel_Disable();
                   lblStatus.Text = "This Account is locked and has moved to supervisor";
                   ModalPopupExtender.Show();
               }
               else
               {
                   Session["Loan_acct"] = ((HiddenField)row.FindControl("hidLoanNo")).Value;
                   Session["Cycle_cut"] = ((HiddenField)row.FindControl("hidCycleCut")).Value;
                   Session["Bucket_Code"] = ((HiddenField)row.FindControl("hidBucketCode")).Value;
                   Session["Module"] = ((HiddenField)row.FindControl("hid_Mod")).Value;
                   Session["Product"] = ((HiddenField)row.FindControl("hid_Prod")).Value;
                   Session["City"] = ((HiddenField)row.FindControl("hid_City")).Value;
                   Session["Billing_Cycle"] = ((HiddenField)row.FindControl("hid_BillingCycle")).Value;
                   this.Tabs.Visible = true;
                   this.pnl_ActLog.Visible = true;
                   ShowFinancial();
                   ShowSituationSummary();
                   Show_PIL_Overdue();
                   ShowActivity();
                   ShowAppInfo();
                   ShowDelinquencyHistory();
                   ShowSchedule();
                   ShowContacts();
                   Show_Diary();
                   Load_All();
                   Show_Actions();
                   Show_DiaryNote();
                   Reset();
               }
           }
           lbl_Status.Text = "";
       }
       catch (Exception ex)
       {
           throw new Exception("Application Error: " + ex.Message);
       }

解决方案

If all you are attempting to do is select the first gridview row for editing when the page loads, try setting the EditIndex property of the gridview before you call the grid's DataBind() method. Like so...

GridView1.EditIndex = 0;


这篇关于如何在页面加载的第一行gridview.rowcommand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆