Click here to Skip to main content
11,479,412 members (53,988 online)

24983 asked:

Open original thread
Hi,

Thanks in advance,
Im developing in portal I created dynamically four columns in gridview rowdata bound .first column is client,2nd columns in role/position,3rd column in from date -todate (dropdownlist),fourth columns is contnent These are executed when parsing resume.Ineed alignment for these fourcolumns,

protected void WorkExp_Grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
              if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if (e.Row.Cells[0].Text.Length == 0 || e.Row.Cells[0].Text.Equals(" ") || e.Row.Cells[0].Text.Equals("") || e.Row.Cells[0].Text.Equals(string.Empty))
                    {
                        e.Row.Cells[0].Text = string.Empty;
                    }
 
                    
                    // Start Date
                    string[] startdate = e.Row.Cells[2].Text.Split('/');
 
                    DropDownList s_m_dl1 = new DropDownList();
                    s_m_dl1.DataSource = monthDataSource();
                    s_m_dl1.DataBind();
                    s_m_dl1.SelectedIndex = Convert.ToInt32(startdate[1]);
 
                    DropDownList s_y_dl1 = new DropDownList();
                    s_y_dl1.DataSource = yearDataSource();
                    s_y_dl1.DataBind();
                    s_y_dl1.SelectedIndex = Convert.ToInt32(startdate[2]);
                    s_y_dl1.Width = 100;
                    Image mandImg1 = new ImageButton();
                    mandImg1.ImageUrl = "../common/images/Mandatory.gif";
 
                    e.Row.Cells[2].Controls.Add(mandImg1);
                    e.Row.Cells[2].Controls.Add(s_m_dl1);
                    e.Row.Cells[2].Controls.Add(new LiteralControl("<br><br>  "));
                    e.Row.Cells[2].Controls.Add(s_y_dl1);
 

                    //Shankar : End Date
                    string[] enddate = e.Row.Cells[3].Text.Split('/');
 
                    DropDownList e_m_dl1 = new DropDownList();
                    e_m_dl1.DataSource = monthDataSource();
                    e_m_dl1.DataBind();
                    e_m_dl1.SelectedIndex = Convert.ToInt32(enddate[1]);
 
                    DropDownList e_y_dl1 = new DropDownList();
                    e_y_dl1.DataSource = yearDataSource();
                    e_y_dl1.DataBind();
                    e_y_dl1.SelectedIndex = Convert.ToInt32(enddate[2]);
                    e_y_dl1.Width = 100;
                    Image mandImg2 = new ImageButton();
                    mandImg2.ImageUrl = "../common/images/Mandatory.gif";
 
                    e.Row.Cells[3].Controls.Add(mandImg2);
                    
                    e.Row.Cells[3].Controls.Add(e_m_dl1);
                    e.Row.Cells[3].Controls.Add(new LiteralControl("<br><br>  "));
 
                    e.Row.Cells[3].Controls.Add(e_y_dl1);
 

                    //Shankar : ClientID textbox
                    TextBox txtClientData = new TextBox();
                    txtClientData.Text = e.Row.Cells[0].Text;
                    txtClientData.ID = "clientTXT";
 
                    AjaxControlToolkit.FilteredTextBoxExtender FtxtClientData = new AjaxControlToolkit.FilteredTextBoxExtender();
                    FtxtClientData.FilterMode = AjaxControlToolkit.FilterModes.InvalidChars;
                    FtxtClientData.InvalidChars = "<>#$%&():+=~`_-|@*~!^?/;\",'\\[]{}";
                    FtxtClientData.TargetControlID = txtClientData.ID;
                    txtClientData.Height = 11;
                    
                    Image mandImg3 = new ImageButton();
                    mandImg3.ImageUrl = "../common/images/Mandatory.gif";
 
                    Label lblProjNum = new Label();
                    lblProjNum.Text = "Project " + (e.Row.DataItemIndex + 1).ToString();
                    lblProjNum.Attributes.Add("style", "font-weight:bold;font-size:12px");
 
                    e.Row.Cells[0].Controls.Add(mandImg3);
                    e.Row.Cells[0].Controls.Add(txtClientData);
                    e.Row.Cells[0].Controls.Add(FtxtClientData);
                    e.Row.Cells[0].Controls.Add(new LiteralControl("<br>"));
                    e.Row.Cells[0].Controls.Add(lblProjNum);
 
                    //Shankar : Position/Role textbox
                    TextBox txtPosRole = new TextBox();
                    if (e.Row.Cells[1].Text.Length == 0 || e.Row.Cells[1].Text.Equals(" ") || e.Row.Cells[1].Text.Equals("") || e.Row.Cells[1].Text.Equals(string.Empty))
                    {
                        //e.Row.Cells[1].Text = " ";
                        e.Row.Cells[1].Text = string.Empty;
                    }
                    txtPosRole.Text = e.Row.Cells[1].Text;
                    txtPosRole.ID = "txtPosRoleID";
 
                    AjaxControlToolkit.FilteredTextBoxExtender FtxtPosRole = new AjaxControlToolkit.FilteredTextBoxExtender();
                    FtxtPosRole.FilterMode = AjaxControlToolkit.FilterModes.InvalidChars;
                    FtxtPosRole.InvalidChars = "<>#$%&():+=~`_-|@*~!^?/;\",'\\[]{}";
                    FtxtPosRole.TargetControlID = txtPosRole.ID;
                    txtPosRole.Height = 11;
 
                    e.Row.Cells[1].Controls.Add(txtPosRole);
                    e.Row.Cells[1].Controls.Add(FtxtPosRole);
 
                    //Shankar : Project content
                    TextBox txtProjDesc = new TextBox();
                    txtProjDesc.ID = "txtProjDescID" + e.Row.RowIndex.ToString();
                    //txtProjDesc.Attributes.Add("onkeypress", "javascript:return fnCheckAlphabets(event);");

                    AjaxControlToolkit.FilteredTextBoxExtender FtxtProjDesc = new AjaxControlToolkit.FilteredTextBoxExtender();
                    FtxtProjDesc.FilterMode = AjaxControlToolkit.FilterModes.InvalidChars;
                    FtxtProjDesc.InvalidChars = "<>$%&()=~`_|@*~!^?/;\"'\\[]{}";
                    FtxtProjDesc.TargetControlID = txtProjDesc.ID;
                    //txtProjDesc.Attributes.Add("onkeypress", "javascript:return fnCheckAlphabets(event);");
                    
                    txtProjDesc.TextMode = TextBoxMode.MultiLine;
                    txtProjDesc.Rows = 10;
                    txtProjDesc.Columns = 30;
 
                    if (e.Row.Cells[4].Text.Length == 0 || e.Row.Cells[4].Text.Equals(" ") || e.Row.Cells[4].Text.Equals("") || e.Row.Cells[4].Text.Equals(string.Empty))
                    {
                        e.Row.Cells[4].Text = string.Empty;
                    }
 
                    txtProjDesc.Text = e.Row.Cells[4].Text;
                    txtProjDesc.Text = txtProjDesc.Text.Replace(" ", "");
                    txtProjDesc.Font.Size = FontUnit.Small;
                    e.Row.Cells[4].Controls.Add(txtProjDesc);
                    e.Row.Cells[4].Controls.Add(FtxtProjDesc);
 
                    //Shankar : Delete Project Button
                    ImageButton imgDelProject = new ImageButton();
                    imgDelProject.Attributes.Add("runat", "server");
                    imgDelProject.CausesValidation = false;
                    //imgDelProject.Attributes.Add("UseSubmitBehavior", "true");
                    //imgDelProject.OnClientClick = "$(this).SuccessBox('Project has been deleted successfully.'); return false;";
                    imgDelProject.OnClientClick = "javascript:collectJSONData(); return ConfirmDeleteProject();";
                    imgDelProject.EnableViewState = true;
                    imgDelProject.ImageUrl = "../common/images/delete.jpg";
                    imgDelProject.ToolTip = "Delete Project";
                    imgDelProject.Command += new System.Web.UI.WebControls.CommandEventHandler(this.DeleteProject);
                    imgDelProject.CommandName = e.Row.DataItemIndex.ToString();
                    e.Row.Cells[5].Controls.Add(imgDelProject);
 
                }
        }

[edit]code block added[/edit]
Tags: ASP.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100