Skip to main content

how to use Gridview row in function..

how ot use Gridview row in function..

private void SetSelectedJob()
        {
            if (ViewState["_selectedJob"] == null)
            {
                _selectedJob = new List<Job>();
            }
            else
            {
                _selectedJob = ViewState["_selectedJob"] as List<Job>;
            }
            foreach (GridViewRow row in grdBookingRecievedShipper.Rows)
            {
                if (row.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }
                HtmlInputCheckBox chkSelectRFQ = row.FindControl("chkSelectJob") as HtmlInputCheckBox;
                long JobId = (long)grdBookingRecievedShipper.DataKeys[row.RowIndex].Values[0];
                if (chkSelectRFQ.Checked)
                {
                    Job job = new Job((long)grdBookingRecievedShipper.DataKeys[row.RowIndex].Values[0]);


                    if (_selectedJob != null && _selectedJob.Where(r => r.Id == JobId).Count() == 0)
                    {
                        _selectedJob.Add(job);
                    }

                }
                else if (_selectedJob != null && _selectedJob.Where(r => r.Id == JobId).Count() > 0)
                {
                    _selectedJob.RemoveAll(r => r.Id == JobId);
                }

            }
            ViewState["_selectedJob"] = _selectedJob;
        }

Popular posts from this blog

Add barcode on pdf

using System; using System.IO; using System.Drawing; using ZXing; using iTextSharp.text; using iTextSharp.text.pdf; using System.Drawing; using System.Web.UI.WebControls; namespace PDFBarcode {     public partial class WebForm1 : System.Web.UI.Page     {         byte[] byteImage;         protected void Page_Load(object sender, EventArgs e)         {         }         protected void btnDownload_Click(object sender, EventArgs e)         {                       Random r = new Random();             string fileName = r.Next().ToString();             string filenameext = fileName + ".pdf";             GenerateBarcode(fileName);             string Sourcepath = Server.MapPath("~/SavedF...

Dynamic Menu in asp.net using Listview

 1.    public DataTable LoadMenu()         {             MenuBal MenuBal = new MenuBal();             DataSet ds = this.GetData(0);             PopulateMenu(ds);             return ds.Tables[2];         }     private DataSet GetData(int parentMenuId)         {             MenuBal objmenu = new MenuBal();             string Mode = "";             if (Session["Mode"] != null)             {                 Mode = Session["Mode"].ToString();             }             DataSet ds = objmenu.GetData(parentMenuId, Convert.ToInt32(SessionHelper.CurrentUserId), Mode, SessionHelper...