views:

23

answers:

1

i have a gridview with columns as

datetime name status

i need to update the column record , so i used:

<asp:CommandField ShowEditButton="true" ButtonType="Link" EditText="Edit" ShowHeader="true" HeaderText="Edit" HeaderStyle-Font-Bold="true" Visible="true"> <HeaderStyle Font-Bold="True" />
</asp:CommandField>

and in rowediting event:

 protected void GrdDynamicControls_RowEditing(object sender, GridViewEditEventArgs e)
{

GrdDynamicControls.EditIndex = e.NewEditIndex;
}

if i hit edit command by default it is showing me oly textbox, but i need datepicker and checkbox to be displayed in edit mode. how to bring that.

any idea???

A: 

Suggest you use a TemplateField with a Label and CheckBox in the ItemTemplate, and a TextBox with AjaxControlToolkit DatePicker and CheckBox in the EditTemplate:

<%@ Register TagPrefix="ajaxtoolkit" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"  %>

<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager" />
<div>
<asp:GridView runat="server" ID="MyGridView">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Label runat="server" ID="DisplayLabel" Text='<%# Eval("DateDataItem") %>' />
                <asp:CheckBox runat="server" ID="DisplayCheckBox" Checked='<%# Eval("BooleanDataItem %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="EditTextBox" Text='<%# Eval("DateDataItem") %>' />
                <ajaxtoolkit:CalendarExtender runat="server" ID="EditTextBoxCalendarExtender" TargetControlID="EditTextBox" />
                <asp:CheckBox runat="server" ID="DisplayCheckBox" Checked='<%# Eval("BooleanDataItem %>' /> 
            </EditItemTemplate>
       </asp:TemplateField>
       <asp:CommandField ShowEditButton="true" ButtonType="Link" EditText="Edit" 
ShowHeader="true" HeaderText="Edit" HeaderStyle-Font-Bold="true" Visible="true" HeaderStyle-Font-Bold="True" />

    </Columns>
</asp:GridView>
PhilPursglove