Click here to Skip to main content
15,914,416 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDatagridview with scroll bar. Pin
Member 47041432-Dec-09 16:32
Member 47041432-Dec-09 16:32 
AnswerRe: Datagridview with scroll bar. Pin
sashidhar2-Dec-09 17:49
sashidhar2-Dec-09 17:49 
AnswerRe: Datagridview with scroll bar. Pin
Anurag Gandhi2-Dec-09 19:43
professionalAnurag Gandhi2-Dec-09 19:43 
AnswerRe: Datagridview with scroll bar. Pin
Dinesh Mani2-Dec-09 19:44
Dinesh Mani2-Dec-09 19:44 
AnswerRe: Datagridview with scroll bar. Pin
Abhijit Jana2-Dec-09 19:52
professionalAbhijit Jana2-Dec-09 19:52 
QuestionDynamic Controls... Pin
Illegal Operation2-Dec-09 12:45
Illegal Operation2-Dec-09 12:45 
AnswerRe: Dynamic Controls... Pin
dan!sh 2-Dec-09 15:41
professional dan!sh 2-Dec-09 15:41 
GeneralRe: Dynamic Controls... Pin
Illegal Operation2-Dec-09 15:50
Illegal Operation2-Dec-09 15:50 
Here is the code as it works now. Everytime you click the add button it should just duplicate the existing row.

private int numOfRows = 1;

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        GenerateTable(numOfRows);
    }
}

private void GenerateTable(int numOfRows)
{
    Table tblTimesheet = new Table();
    tblTimesheet.ID = "tblTimesheet";
    placeHolder.Controls.Add(tblTimesheet);

    const int colsCount = 12;

    for (int i = 0; i < numOfRows; i++)
    {
        TableRow HeaderRow = new TableRow();

        TableRow newRow = new TableRow();

        for (int j = 0; j < colsCount; j++)
        {
            TableCell newCell = new TableCell();
            newCell.HorizontalAlign = HorizontalAlign.Center;

            TextBox txtWeekday = new TextBox();
            txtWeekday.ID = "txtWeekday" + j;
            txtWeekday.Width = 80;

            CheckBox chkLunchCrib = new CheckBox();
            chkLunchCrib.ID = "chkLunchCrib" + j;
            chkLunchCrib.Checked = false;

            if (txtWeekday.ID == "txtWeekday11" || txtWeekday.ID == "txtWeekday10" || txtWeekday.ID == "txtWeekday9")
            {
                txtWeekday.Visible = false;
            }

            if (chkLunchCrib.ID == "chkLunchCrib0" || chkLunchCrib.ID == "chkLunchCrib1" || chkLunchCrib.ID == "chkLunchCrib2" || chkLunchCrib.ID == "chkLunchCrib3" || chkLunchCrib.ID == "chkLunchCrib4" || chkLunchCrib.ID == "chkLunchCrib5" || chkLunchCrib.ID == "chkLunchCrib6" || chkLunchCrib.ID == "chkLunchCrib7" || chkLunchCrib.ID == "chkLunchCrib8")
            {
                chkLunchCrib.Visible = false;
            }

            #region Date Selection.

            TextBox txtCalendar = new TextBox();
            txtCalendar.ID = "txtCalendar" + j;
            txtCalendar.Width = 155;
            txtCalendar.Text = DateTime.Today.ToShortDateString();

            ImageButton imgbtnCalendar = new ImageButton();
            imgbtnCalendar.ID = "imgbtnCalendar";
            imgbtnCalendar.ImageUrl = "~/Resources/Calendar_scheduleHS.png";
            imgbtnCalendar.ImageAlign = ImageAlign.AbsMiddle;

            AjaxControlToolkit.CalendarExtender ajaxCalExt = new AjaxControlToolkit.CalendarExtender();
            ajaxCalExt.ID = "ajaxCalExt";
            ajaxCalExt.TargetControlID = "txtCalendar" + j;
            ajaxCalExt.PopupButtonID = "imgbtnCalendar";

            #endregion

            if (txtCalendar.ID == "txtCalendar0" && txtWeekday.ID == "txtWeekday0")
            {
                newCell.Controls.Add(txtCalendar);
                newCell.Controls.Add(imgbtnCalendar);
                newCell.Controls.Add(ajaxCalExt);
                txtWeekday.Visible = false;
            }

            newCell.Controls.Add(txtWeekday);
            newCell.Controls.Add(chkLunchCrib);
            newRow.Cells.Add(newCell);
        }

        tblTimesheet.Rows.Add(HeaderRow);
        tblTimesheet.Rows.Add(newRow);
    }

    numOfRows++;
    ViewState["RowsCount"] = numOfRows;
}

protected void btnAdd_Click(object sender, EventArgs e)
{
    if (ViewState["RowsCount"] != null)
    {
        numOfRows = Convert.ToInt32(ViewState["RowsCount"].ToString());
        GenerateTable(numOfRows);
    }
}


Illegal Operation

GeneralRe: Dynamic Controls... Pin
saini arun2-Dec-09 19:09
saini arun2-Dec-09 19:09 
GeneralRe: Dynamic Controls... Pin
Dinesh Mani2-Dec-09 19:35
Dinesh Mani2-Dec-09 19:35 
Questionaspx page in iframe reloading issues Pin
robustm2-Dec-09 3:56
robustm2-Dec-09 3:56 
AnswerRe: aspx page in iframe reloading issues Pin
Abhishek Sur2-Dec-09 4:45
professionalAbhishek Sur2-Dec-09 4:45 
GeneralRe: aspx page in iframe reloading issues Pin
robustm2-Dec-09 5:08
robustm2-Dec-09 5:08 
QuestionHow to open URL in new browser window Pin
Nekkantidivya2-Dec-09 1:08
Nekkantidivya2-Dec-09 1:08 
AnswerRe: How to open URL in new browser window Pin
Dinesh Mani2-Dec-09 1:25
Dinesh Mani2-Dec-09 1:25 
AnswerRe: How to open URL in new browser window Pin
sumit70342-Dec-09 1:43
sumit70342-Dec-09 1:43 
AnswerRe: How to open URL in new browser window Pin
Abhishek Sur2-Dec-09 1:48
professionalAbhishek Sur2-Dec-09 1:48 
AnswerRe: How to open URL in new browser window Pin
Gamzun2-Dec-09 3:19
Gamzun2-Dec-09 3:19 
AnswerRe: How to open URL in new browser window Pin
Christopher Duncan2-Dec-09 4:08
Christopher Duncan2-Dec-09 4:08 
QuestionCell Format in excel. [modified] Pin
dayakar_dn2-Dec-09 0:34
dayakar_dn2-Dec-09 0:34 
AnswerRe: Cell Format in excel. Pin
Dinesh Mani2-Dec-09 0:46
Dinesh Mani2-Dec-09 0:46 
AnswerRe: Cell Format in excel. Pin
Abhishek Sur2-Dec-09 3:09
professionalAbhishek Sur2-Dec-09 3:09 
AnswerRe: Cell Format in excel. Pin
Gamzun2-Dec-09 3:20
Gamzun2-Dec-09 3:20 
QuestionThe server rejected one or more recipient addresses. The server response was: 501 5.5.4 Invalid Address Pin
Amit Spadez1-Dec-09 23:43
professionalAmit Spadez1-Dec-09 23:43 
AnswerRe: The server rejected one or more recipient addresses. The server response was: 501 5.5.4 Invalid Address Pin
Abhijit Jana1-Dec-09 23:47
professionalAbhijit Jana1-Dec-09 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.