Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
490
Migrating from 2011 vol 1 ultrawebgrid to webdatagrid 2016 vol 2
posted

Hi,

I need help with sample code on migrating the following events. Sample code attached below.

InitializeLayout

TemplatedColumnRestored

InitializeRow using templated columns

Thanks for your help.

 

 

protected void wbgData_InitializeLayout(object sender, LayoutEventArgs e)

//bool addABlank = false;


switch (_reportID)

{

case "DDC":

{

//this.wbgData.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center;


//this.wbgData.DisplayLayout.HeaderStyleDefault.VerticalAlign = VerticalAlign.Middle;


// All the Headers for bound columns initialize to OriginX = 0. Since we want them


// to appear below the added column headers we are going to need to move them down a level


foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in e.Layout.Bands[0].Columns)

{

c.Header.RowLayoutColumnInfo.OriginY = 1;

}

// now add an unbound header


Infragistics.WebUI.UltraWebGrid.ColumnHeader ch = new Infragistics.WebUI.UltraWebGrid.ColumnHeader(true);

 

ch.Caption = "Scheduled To Be Delivered";

 

ch.Style.HorizontalAlign = HorizontalAlign.Center;

 

ch.Style.VerticalAlign = VerticalAlign.Middle;

// set the origin to be on the top most level of the header

 

ch.RowLayoutColumnInfo.OriginY = 0;

// set the newly added column to be in the correct location

 

ch.RowLayoutColumnInfo.OriginX = 2;

// extend the newly added header over 6 columns

 

ch.RowLayoutColumnInfo.SpanX = 6;

// add an image to the header object.


//ch.Image.Url = "./images/bankingbtn.gif";


//ch.Image.AlternateText = "Employee Name Grouping";


// add the header into the header layout


e.Layout.Bands[0].HeaderLayout.Add(ch);

 

 

 

}

break;

 

default:

 

break;

}

}

protected void wbgData_TemplatedColumnRestored(object sender, ColumnEventArgs e)

{

if (((TemplatedColumn)e.Column).CellTemplate == null)

{

((TemplatedColumn)e.Column).CellTemplate = new PlaceHolderTemplate();

}

}

//protected void wbgData_InitializeRow(object sender, RowEventArgs e)
        protected void wbgData_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
        {
            UltraWebGrid grid = sender as UltraWebGrid;
            TemplatedColumn tc;
            CellItem ci;
            LinkButton lnk;

            string s, strTrackingNum;
           
           

            //Switch on Templated column id
            switch (_reportID)
     {
                        case "DDC":
                           
                            tc = (TemplatedColumn)e.Row.Cells.FromKey("DDC").Column;
                            ci = (CellItem)tc.CellItems[e.Row.Index];
                            lnk = (LinkButton)ci.FindControl("LinkButton1");
                            if (lnk != null)
                            {
                                //int i = 0;
                                lnk.Text = tblShipment.Rows[e.Row.Index][1].ToString();
                                lnk.ID = _arrLnkId[e.Row.Index];


                                lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDC');";
                                //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                lnk.ForeColor = Color.Black;
                                lnk.Click += new EventHandler(this.lnk_Click);
                                //lnk.ID = _reportDate;

                            }

                            tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCARG").Column;
                            ci = (CellItem)tc.CellItems[e.Row.Index];
                            lnk = (LinkButton)ci.FindControl("LinkButton1");
                            if (lnk != null)
                            {
                                //int i = 0;
                                lnk.Text = tblShipment.Rows[e.Row.Index][2].ToString();
                                if (lnk.Text == null || lnk.Text == "" || lnk.Text == "0" || lnk.Text == "N/A")
                                {
                                    lnk.Enabled = false;
                                }
                                else
                                {
                                    lnk.Enabled = true;
                                }
                                lnk.ID = _arrLnkId[e.Row.Index] + "ARG" + tblShipment.Rows[e.Row.Index][1].ToString();
                               
                                //tc.Key;
                                lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDC');";
                                //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                lnk.ForeColor = Color.Black;
                                lnk.Click += new EventHandler(this.lnk_Click);
                                //lnk.ID = _reportDate;

                            }

                            tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCUPS").Column;
                            ci = (CellItem)tc.CellItems[e.Row.Index];
                            lnk = (LinkButton)ci.FindControl("LinkButton1");
                            if (lnk != null)
                            {
                                //int i = 0;
                                lnk.Text = tblShipment.Rows[e.Row.Index][4].ToString();
                                if (lnk.Text == null || lnk.Text == "" || lnk.Text == "0" || lnk.Text == "N/A")
                                {
                                    lnk.Enabled = false;
                                }
                                else
                                {
                                    lnk.Enabled = true;
                                }
                                lnk.ID = _arrLnkId[e.Row.Index] + "UPS" + tblShipment.Rows[e.Row.Index][1].ToString();

                                //tc.Key;
                                lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDC');";
                                //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                lnk.ForeColor = Color.Black;
                                lnk.Click += new EventHandler(this.lnk_Click);
                                //lnk.ID = _reportDate;

                            }

                            tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCALL").Column;
                            ci = (CellItem)tc.CellItems[e.Row.Index];
                            lnk = (LinkButton)ci.FindControl("LinkButton1");
                            if (lnk != null)
                            {
                                //int i = 0;
                                lnk.Text = tblShipment.Rows[e.Row.Index][6].ToString();
                                if (lnk.Text == null || lnk.Text == "" || lnk.Text == "0" || lnk.Text == "N/A")
                                {
                                    lnk.Enabled = false;
                                }
                                else
                                {
                                    lnk.Enabled = true;
                                }

                                lnk.ID = _arrLnkId[e.Row.Index] + "ALL" + tblShipment.Rows[e.Row.Index][1].ToString();

                                //tc.Key;
                                lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDC');";
                                //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                lnk.ForeColor = Color.Black;
                                lnk.Click += new EventHandler(this.lnk_Click);
                                //lnk.ID = _reportDate;

                            }
                                  
                                    break;
                        case "DDCTL":
                                    tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCTL").Column;
                                    ci = (CellItem)tc.CellItems[e.Row.Index];
                                    lnk = (LinkButton)ci.FindControl("LinkButton2");
                                    if (lnk != null)
                                    {
                                       
                                        lnk.Text = tblShipment.Rows[e.Row.Index][1].ToString();
                                        lnk.ID = _arrLnkId[e.Row.Index];
                                        lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                        //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDCTL');";
                                        lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                        lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                        lnk.ForeColor = Color.Black;
                                        lnk.Click += new EventHandler(this.lnk_Click);
                                       

                                    }
                                  

                                    tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCTLDET").Column;
                                    ci = (CellItem)tc.CellItems[e.Row.Index];
                                    lnk = (LinkButton)ci.FindControl("LinkButton2");
                                    if (lnk != null)
                                    {
                                       
                                        lnk.Text = tblShipment.Rows[e.Row.Index][3].ToString();

                                        if (_arrLnkId[e.Row.Index].Substring(6,3) == "ARG") //DDCTL0ARG000
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + tblShipment.Rows[e.Row.Index][1].ToString();
                                        }
                                        else if (_arrLnkId[e.Row.Index].Substring(7, 3) == "ARG") //DDCTL10ARG000
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + tblShipment.Rows[e.Row.Index][1].ToString();
                                        }

                                       
                                        if (_arrLnkId[e.Row.Index].Substring(6, 3) == "ARN") //DDCTL0ARN000
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + tblShipment.Rows[e.Row.Index][1].ToString();
                                        }
                                        else if (_arrLnkId[e.Row.Index].Substring(7, 3) == "ARN") //DDCTL10ARN000
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + tblShipment.Rows[e.Row.Index][1].ToString();
                                        }
                                        //End Anil Madan

                                        else if (_arrLnkId[e.Row.Index].Substring(6, 3) == "UPS") //DDCTL0UPS003
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + "00000000";
                                        }
                                        else if (_arrLnkId[e.Row.Index].Substring(7, 3) == "UPS") //DDCTL10UPS003
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + "00000000";
                                        }

                                        
                                        else if (_arrLnkId[e.Row.Index].Substring(6, 3) == "UPN") //DDCTL0UPN003
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + "00000000";
                                        }
                                        else if (_arrLnkId[e.Row.Index].Substring(7, 3) == "UPN") //DDCTL10UPN003
                                        {
                                            //Append TL
                                            lnk.ID = _arrLnkId[e.Row.Index] + "00000000";
                                        }

                                       

                                        lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                        //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDCTL');";
                                        lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                        lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                        lnk.ForeColor = Color.Black;
                                        lnk.Click += new EventHandler(this.lnk_Click);


                                    }
                                    break;

                        case "DDCTLV":
                                    tc = (TemplatedColumn)e.Row.Cells.FromKey("DDCTLV").Column;
                                    ci = (CellItem)tc.CellItems[e.Row.Index];
                                    lnk = (LinkButton)ci.FindControl("LinkButton3");
                                    if (lnk != null)
                                    {
                                        //int i = 0;
                                        lnk.Text = tblShipment.Rows[e.Row.Index][0].ToString();
                                        lnk.ID = _arrLnkId[e.Row.Index];

                                        lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                                        //lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDCTLV');";
                                        //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                        //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                        lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                        lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                        lnk.ForeColor = Color.Black;
                                        lnk.Click += new EventHandler(this.lnk_Click);
                                        //lnk.ID = _reportDate;

                                    }
                                    break;
                        case "DDCCD":
                                    if (e.Row.Cells.FromKey("TrackingNumber").Value != null)
                                    {
                                        strTrackingNum = e.Row.Cells.FromKey("TrackingNumber").Value.ToString();

                                        strTrackingNum = strTrackingNum.ToUpper();

                                        if (strTrackingNum.StartsWith("1Z"))
                                        {
                                            //get the query string

                                            s = "/Dctracking/upsActivity.aspx?Tracking_Number=" + e.Row.Cells.FromKey("TrackingNumber").Value.ToString();
                                            //set the TargetURL
                                            //e.Row.Cells.FromKey("Tracking Number").TargetURL ="@" + s;
                                            e.Row.Cells.FromKey("TrackingNumber").TargetURL = s;

                                        }
                                    }
                                    break;

                        default: //_tcId == null
                                    /*
                                    tc = (TemplatedColumn)e.Row.Cells.FromKey("DDC").Column;
                                     ci = (CellItem)tc.CellItems[e.Row.Index];
                                    lnk = (LinkButton)ci.FindControl("LinkButton1");
                                    if (lnk != null)
                                    {
                                        //int i = 0;
                                        lnk.Text = tblShipment.Rows[e.Row.Index][1].ToString();
                                        lnk.ID = _arrLnkId[e.Row.Index];
                                       
                                        //tc.Key;
                                        lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "','DDC');";
                                        //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                                        //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                                        lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                                        lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                                        lnk.ForeColor = Color.Black;
                                        lnk.Click += new EventHandler(this.lnk_Click);
                                        //lnk.ID = _reportDate;

                                    }*/

                                    break;
                                    
                    }
            

            if (_reportID == null)
            {

            }

            if (_bPClick == null)
            {

            }
            //_bPClick.ToString();
            /*
            TemplatedColumn tc = (TemplatedColumn)e.Row.Cells.FromKey("DDC").Column;
            CellItem ci = (CellItem)tc.CellItems[e.Row.Index];
            LinkButton lnk = (LinkButton)ci.FindControl("LinkButton1");
            if (lnk != null)
            {
                //int i = 0;
                lnk.Text = tblShipment.Rows[e.Row.Index][1].ToString();
                lnk.ID = _arrLnkId[e.Row.Index];

                lnk.Attributes["onclick"] = "javascript:buttonClick('" + lnk.Text + "');";
                //lnk.Attributes.Add("onClick", "buttonClick('"tblShipment.Rows[e.Row.Index][1].ToString()"');");
                //lnk.Attributes["onclick"] = "javascript:buttonClick('" + _oDr.GetString(i - 1).Trim() + "');";
                lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'";
                lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'";
                lnk.ForeColor = Color.Black;
                lnk.Click += new EventHandler(this.lnk_Click);
                //lnk.ID = _reportDate;

            }
             * /
            //lnk.Text = "test";
            //lnk.Text = _reportDate;
            /*
            UltraWebGrid grid = sender as UltraWebGrid;

            //2nd column
            TemplatedColumn tc = grid.Columns[0] as TemplatedColumn;
           
            CellItem item = tc.CellItems[e.Row.BandIndex] as CellItem;
           
            LinkButton linkbutton = item.FindControl("LinkButton1") as LinkButton;


            if (linkbutton != null)
            {

                e.Row.Cells[0].Value = _reportDate;

            }*/
            
            
        }

Thanks for your help.

SALES

North America
sales@infragistics.com
Sales: +1 (800) 231 8588
Fax: +1 (732) 831 7820

Europe
sales-europe@infragistics.com
Sales: +44 (0) 800 298 9055