Hi all,
I have a problem with some code and I'm not sure what's going on. When my page first loads, my Page Load event fires fine. I'm locating the footer field of active date and rendering it readonly and setting the onclick on the input button to javascript to fire if clicked. Works great till I click on the edit button on any of my gridview rows and then none of my Page Load event changes get loaded or at least get overwritten by another event. I need a clue here. Posting snippet code for aspx page and then the cs page.
cs code snippet:
Also, two sided problem. I can't get to the EditTemplate field to do the same thing. I tried OnRowEditing but that's no good because I can't get to the ClientID. Any ideas?
Thanks for the help.
I have a problem with some code and I'm not sure what's going on. When my page first loads, my Page Load event fires fine. I'm locating the footer field of active date and rendering it readonly and setting the onclick on the input button to javascript to fire if clicked. Works great till I click on the edit button on any of my gridview rows and then none of my Page Load event changes get loaded or at least get overwritten by another event. I need a clue here. Posting snippet code for aspx page and then the cs page.
Code:
<asp:TemplateField HeaderText="Active Date" SortExpression="active_date">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("active_date", "{0:MM/dd/yyyy}") %>'
MaxLength="10" Width="70px" ></asp:TextBox><input type="button" runat="server" value="Cal" id="btnCal"/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("active_date", "{0:MM/dd/yyyy}") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtActivedate" runat="server" Text='01/01/2007' MaxLength="10" Width="70px"></asp:TextBox><input
type="button" runat="server" value="Cal" id="btCal" />
</FooterTemplate>
</asp:TemplateField>
cs code snippet:
Code:
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
string str = dt.ToString("MM/dd/yyyy");
((TextBox)GridView1.FooterRow.FindControl("txtActivedate")).Attributes.Add("readonly", "true");
TextBox active_date = GridView1.FooterRow.FindControl("txtActivedate") as TextBox;
string adate = active_date.ClientID;
((TextBox)GridView1.FooterRow.FindControl("txtActivedate")).Text = str;
((HtmlInputButton)GridView1.FooterRow.FindControl("btCal")).Attributes.Add("onclick", "displayCalendar(document.getElementById('" + adate + "'),'mm/dd/yyyy',this);");
}
Also, two sided problem. I can't get to the EditTemplate field to do the same thing. I tried OnRowEditing but that's no good because I can't get to the ClientID. Any ideas?
Thanks for the help.