//Add below javascript to header section on aspx page
<script type="text/javascript">
$(function () {
var strdateFormat = "<%=ReqDateFormat %>";
strdateFormat = strdateFormat.replace('MM', 'mm');
strdateFormat = strdateFormat.replace('MMM', 'mmm');
strdateFormat = strdateFormat.replace('yyyy', 'yy');
//alert(strdateFormat);
// $("[id$=txtRequestedDate]").datepicker({
// showOn: 'button',
// buttonImageOnly: true,
// buttonImage: 'images/calendarbtn.gif',
// dateFormat: strdateFormat
// });
//});
var n = 0;
$("[id*='txtRequestedDate']").each(function () {
n++;
tempField = this.id.split("-");
this.id = tempField[0] + "-" + n;
$("#" + this.id).datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: 'images/calendarbtn.gif',
dateFormat: strdateFormat
});
});
});
</script>
<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateColumn>
<ItemStyle Width="150px" />
<ItemTemplate>
<asp:TextBox ID="txtitem" Width="100px" runat="server" MaxLength="25"></asp:TextBox>
<asp:HiddenField ID="hdnTxtItem" runat="server" />
<asp:ImageButton ID="img_search" runat="server" Width="20px" Height="20px" ImageAlign="AbsBottom"
ImageUrl="~/images/magnifying-glass.png"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemStyle CssClass="centerAlignGridColumn" Width="55px" />
<ItemTemplate>
<asp:TextBox ID="txtRequestedDate" Width="120px" MaxLength="12" runat="server"></asp:TextBox>
<%-- <ajaxToolkit:FilteredTextBoxExtender ID="tbqtynumeric" runat="server" TargetControlID="txtQty"
Enabled="true" />--%>
</ItemTemplate>
</asp:TemplateColumn> </Columns>
</asp:DataGrid>
//.cs page bind the datagrid with some data
//You can find the control as shown below
foreach (DataGridItem dgi in DataGrid1.Items)
{
TextBox TReq = (TextBox)dgi.FindControl("txtRequestedDate");
}
No comments:
Post a Comment