示例#1
0
 public void BindGrid()
 {
     col = ObjAsset.Get_By_comandname("A");
     grdvwViewAsset.DataSource = col;
     grdvwViewAsset.DataBind();
     ViewState["commandname"] = "a";
 }
示例#2
0
    //public void BindGrid()
    //{
    //    lblErrorMsg.Text = "";
    //    col = ObjAsset.Get_By_comandname("A");
    //    grdvwViewAsset.DataSource = col;
    //    grdvwViewAsset.DataBind();
    //    ViewState["commandname"] = "a";

    //}
    //protected void BindGrid1()
    //{
    //    lblErrorMsg.Text = "";
    //    string commandname;
    //    commandname = ViewState["commandname"].ToString();
    //    col = ObjAsset.Get_By_comandname(commandname);
    //    if (col.Count != 0)
    //    {
    //        grdvwViewAsset.DataSource = col;
    //        grdvwViewAsset.DataBind();
    //    }

    //}

    protected void grdvwViewAsset_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        lblErrorMsg.Text = "";
        if (e.CommandName.Equals("AlphaPaging"))
        {
            string commandname = e.CommandArgument.ToString();
            ViewState["commandname"] = e.CommandArgument.ToString();
            col = ObjAsset.Get_By_comandname(commandname);
            if (col.Count != 0)
            {
                grdvwViewAsset.DataSource = col;
                grdvwViewAsset.DataBind();
            }
            else
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("assetid");
                dt.Columns.Add("computername");
                dt.Columns.Add("domain");

                DataRow dr = dt.NewRow();
                dt.Rows.Add(dr);

                grdvwViewAsset.DataSource = dt;
                grdvwViewAsset.DataBind();
            }
        }
    }
    //public void BindGrid()
    //{
    //    lblErrorMsg.Text = "";
    //    col = ObjAsset.Get_By_comandname("A");
    //    grdvwViewAsset.DataSource = col;
    //    grdvwViewAsset.DataBind();
    //    ViewState["commandname"] = "a";

    //}
    //protected void BindGrid1()
    //{
    //    lblErrorMsg.Text = "";
    //    string commandname;
    //    commandname = ViewState["commandname"].ToString();
    //    col = ObjAsset.Get_By_comandname(commandname);
    //    if (col.Count != 0)
    //    {
    //        grdvwViewAsset.DataSource = col;
    //        grdvwViewAsset.DataBind();
    //    }

    //}

    protected void grdvwViewAsset_RowCommand(object sender, GridViewCommandEventArgs e)
    {
/////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            lblErrorMsg.Text = "";
            if (e.CommandName.Equals("AlphaPaging"))
            {
                string commandname = e.CommandArgument.ToString();
                ViewState["commandname"] = e.CommandArgument.ToString();
                col = ObjAsset.Get_By_comandname(commandname);
                if (col.Count != 0)
                {
                    grdvwViewAsset.DataSource = col;
                    grdvwViewAsset.DataBind();
                }
                else
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("assetid");
                    dt.Columns.Add("computername");
                    dt.Columns.Add("domain");

                    DataRow dr = dt.NewRow();
                    dt.Rows.Add(dr);

                    grdvwViewAsset.DataSource = dt;
                    grdvwViewAsset.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }