Hi Sowmya90,
Check with the below code. Paging is working.
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=Grd_Dtls] tr td').on('click', function () {
if ($(this).index() > 1) {
$('[id*=Grd_Dtls] tr td').each(function () {
if ($(this).index() > 1) {
$(this).find('span').show();
$(this).find('input[type=text]').hide();
$(this).find('[id*=ddl_List2]').hide();
$(this).find('span').html($(this).find('input[type=text]').val());
$(this).find('span').html($(this).find('[id*=ddl_List2]').val());
}
});
var val = $(this).find('span').html();
$(this).find('span').hide();
$(this).find('[id*=ddl_List2]').val(val);
$(this).find('[id*=ddl_List2]').show();
$(this).find('[id*=ddl_List2]').focus();
$(this).find('input[type=text]').val(val);
$(this).find('input[type=text]').show();
$(this).find('input[type=text]').focus();
$('[id*=ddl_List2]').on('click', function () {
return false;
});
}
});
});
</script>
<asp:GridView ID="Grd_Dtls" runat="server" AutoGenerateColumns="False" PageSize="2"
AllowPaging="true" OnPageIndexChanging="Grd_Dtls_PageIndexChanging">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:TemplateField HeaderText="Text1">
<ItemTemplate>
<asp:Label ID="lbl_Text1" runat="server" Text='<%# Bind("Text1") %>'></asp:Label>
<asp:TextBox ID="txt_Text1" runat="server" Text='<%# Bind("Text1") %>' CssClass="hideControl"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="List2">
<ItemTemplate>
<asp:Label ID="lbl_List2" runat="server" Text='<%# Bind("List2") %>'></asp:Label>
<asp:DropDownList runat="server" ID="ddl_List2" CssClass="hideControl" SelectedValue='<%# Bind("List2") %>'>
<asp:ListItem Value="0">0</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
CSS
<style type="text/css">
.hideControl
{
display: none;
}
</style>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] {
new System.Data.DataColumn("Id"), new System.Data.DataColumn("Name"),
new System.Data.DataColumn("Text1"), new System.Data.DataColumn("List2") });
dt.Rows.Add(1, "John Hammond", "United States", 0);
dt.Rows.Add(2, "Mudassar Khan", "India", 1);
dt.Rows.Add(3, "Suzanne Mathews", "France", 1);
dt.Rows.Add(4, "Robert Schidner", "Russia", 0);
this.Grd_Dtls.DataSource = dt;
this.Grd_Dtls.DataBind();
}
Screenshot
