วิธีใส่ค่า Popup Calender ใน Texbox ที่อยู่ใน GridView (General question)

คำตอบ วิธีใส่ค่า Popup Calender ใน Texbox ที่อยู่ใน GridView (General question)

  • 25 ตุลาคม 2554 6:03
    ผู้ดูแล
     
     

    ผมมี gridView กับวันที่ เช่น 12/5/2011 อยู่ใน TextBox ครับ

    โดยวันที่จะเปลี่ยนไปตามที่ user เลือก และการเลือกวันที่นี้จะสัมพันธ์กับค่าภายใน TextBox

    ใน TextBox ผมใช้ Button.onclick ในการ popup calender

    ผมใช้โค้ด JavaScript ครับ

    GridView Name:GridView1

    TextBox Name :TxtDate

    Button Name : btnpickdate

     


    Supa Sethasiripong [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

ตอบทั้งหมด

  • 25 ตุลาคม 2554 6:03
    ผู้ดูแล
     
     คำตอบ
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    Button TB = (Button)e.Row.FindControl("btnpickdate");
    TextBox tb = (TextBox)e.Row.FindControl("TxtDate");
    TB.Attributes.Add("onclick", "javascript:showCalendarControl(document.getElementById('" + tb.ClientID + "'))");
    }
    }

    Supa Sethasiripong [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • ทำเครื่องหมายเป็นคำตอบโดย supa_sModerator 28 ตุลาคม 2554 3:07
    •