Solved

Need to fix the following from gridview to repeater.

Posted on 2010-09-06
6
336 Views
Last Modified: 2012-05-10
I need to have the following to work as a repeater
I appreciate any help.
private void SetData()

        {

            int currentCount = 0;

            CheckBox chkAll = (CheckBox)Inbox.HeaderRow.Cells[0].FindControl("chkAll");

            chkAll.Checked = true;

            ArrayList arr = (ArrayList)ViewState["SelectedRecords"];

            for (int i = 0; i < Inbox.Rows.Count; i++)

            {

                CheckBox chk = (CheckBox)Inbox.Rows[i].Cells[0].FindControl("chk");

                if (chk != null)

                {

                    chk.Checked = arr.Contains(Inbox.DataKeys[i].Value);

                    if (!chk.Checked)

                        chkAll.Checked = false;

                    else

                        currentCount++;

                }

            }

            hfCount.Value = (arr.Count - currentCount).ToString();

        }

Open in new window

0
Comment
Question by:omegalove
  • 4
6 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 33613269
whats the issue with this code? what is not working and what error do you get (if any)
0
 

Author Comment

by:omegalove
ID: 33613305
Can you then help me put the following in a gridview form.
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">

    <tr>

        <th class="status" style="text-align: center">

            ?

        </th>

        <th class="cbox" style="text-align: center">

            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />

        </th>

        <th class="sender">

            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="title">

            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="date">

            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="read">

            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>

        </th>

    </tr>

    <asp:Repeater ID="Inbox" runat="server">

        <FooterTemplate>

            <tr class="footer1">

                <td colspan="6" align="right">

                    <asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"

                        OnClick="btnDelete_Click" />

                </td>

            </tr>

            </table>

        </FooterTemplate>

        <ItemTemplate>

            <tr class="post">

                <td align="center">

                    <%--<img src='<%# GetImage(Container.DataItem) %>' />--%>

                </td>

                <td>

                    <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />

                    <%--<a href='<%# yaf.Forum.GetLink(yaf.Pages.cp_message,"pm={0}",DataBinder.Eval(Container.DataItem,"UserPMessageID")) %>'>

                        <%# HtmlEncode(DataBinder.Eval(Container.DataItem,"Subject")) %></a>--%>

                    <%-- <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&UserPMessageID="+Eval("UserPMessageID") + "&FromUsername=" + Eval("FromUsername") %>'>

                          <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.MsgRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%>

                          <%# DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>--%>

                </td>

                <td>

                    <%# DataBinder.Eval(Container.DataItem,IsSentItems ? "ToUser" : "FromUser") %>

                </td>

                <td>

                    <%# DataBinder.Eval(Container.DataItem, "Subject") %>

                </td>

                <td>

                    <%# String.Format("{0:MMM-dd-yyyy HH:mm:ss tt}", ((System.Data.DataRowView)Container.DataItem)["Created"])%>

                    <%--<asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>--%>

                    <%-- </asp:HyperLink>--%>

                </td>

                <td>

                    <%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("IsRead")))%>

                    <asp:Label runat="server" ID="UserPMessageID" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"UserPMessageID") %>' />

                </td>

            </tr>

        </ItemTemplate>

    </asp:Repeater>

    <asp:HiddenField ID="hfCount" runat="server" Value="0" />

    <br />

    (* Note: Message(s) will be automatically deleted after 30 days from the received

    date)

    <br />

Open in new window

0
 

Author Comment

by:omegalove
ID: 33613354
how can I fix the following with the table?
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">

    <tr>

        <th class="status" style="text-align: center">

            ?

        </th>

        <th class="cbox" style="text-align: center">

            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />

        </th>

        <th class="sender">

            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="title">

            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="date">

            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>

        </th>

        <th class="read">

            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>

        </th>

    </tr>

    <asp:GridView ID="Inbox" runat="server" DataKeyNames="messageid" GridLines="None"

        OnPageIndexChanging="OnPaging" OnRowDataBound="Inbox_RowDataBound" Height="20px"

        HorizontalAlign="Center" VerticalAlign="Middle" AllowPaging="true" AllowSorting="true"

        EmptyDataText="No data available." PageSize="5" AutoGenerateColumns="false" CssClass="customers-grid">

        <AlternatingRowStyle Height="25px" HorizontalAlign="Center" BackColor="#D5E5FC" VerticalAlign="Middle" />

        <Columns>

            <asp:TemplateField HeaderText="Delete">

                <HeaderStyle CssClass="delete-member"></HeaderStyle>

                <ItemStyle CssClass="delete-member" Wrap="False"></ItemStyle>

                <HeaderTemplate>

                    <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />

                </HeaderTemplate>

                <ItemTemplate>

                    <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />

                </ItemTemplate>

            </asp:TemplateField>

            <asp:TemplateField>

                <HeaderStyle CssClass="from-pic"></HeaderStyle>

                <ItemStyle CssClass="from-pic" Wrap="False"></ItemStyle>

                <ItemTemplate>

                    <br />

                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>

                        <asp:Image ID="MainPicID" BorderWidth="2" BorderColor="Silver" Style="vertical-align: middle"

                            class="srpic" runat="server" />

                    </asp:HyperLink><br />

                    <%#DataBinder.Eval(Container, "DataItem.FromUsername")%>

                    <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.FromProfileID") %>' />

                </ItemTemplate>

            </asp:TemplateField>

            <asp:TemplateField HeaderText="Subject" HeaderStyle-CssClass="subject" ItemStyle-CssClass="subject">

                <HeaderStyle CssClass="subject" />

                <ItemStyle CssClass="subject" />

                <ItemTemplate>

                    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId") + "&FromUsername=" + Eval("FromUsername") %>'>

		 <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.MsgRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%><%# DataBinder.Eval(Container, "DataItem.Subject") %>

                    </asp:HyperLink>

                </ItemTemplate>

            </asp:TemplateField>

            <asp:TemplateField HeaderText="Message" HeaderStyle-CssClass="body" ItemStyle-CssClass="body">

                <HeaderStyle CssClass="body" />

                <ItemStyle CssClass="body" />

                <ItemTemplate>

                    <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px;">

                        <label>

                            <%#DataBinder.Eval(Container, "DataItem.Body")%>

                        </label>

                    </div>

                </ItemTemplate>

            </asp:TemplateField>

            <asp:BoundField HeaderText="Date" DataField="MsgDate" HtmlEncode="False" DataFormatString="{0:MMM-dd-yyyy hh:mm tt}"

                HeaderStyle-CssClass="date-sent" ItemStyle-CssClass="date-sent">

                <HeaderStyle CssClass="date-sent" />

                <ItemStyle CssClass="date-sent" />

            </asp:BoundField>

            <asp:TemplateField HeaderText="Read" HeaderStyle-CssClass="read" ItemStyle-CssClass="read">

                <HeaderStyle CssClass="read" />

                <ItemStyle CssClass="read" />

                <ItemTemplate>

                    <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>

			<%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("MsgRead")))%>

                    </asp:HyperLink>

                </ItemTemplate>

            </asp:TemplateField>

            <asp:TemplateField HeaderText="Replied" HeaderStyle-CssClass="replied" ItemStyle-CssClass="replied">

                <HeaderStyle CssClass="replied" />

                <ItemStyle CssClass="replied" />

                <ItemTemplate>

                    <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>

			<%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("MsgReplied")))%>

                    </asp:HyperLink>

                </ItemTemplate>

            </asp:TemplateField>

        </Columns>

    </asp:GridView>

    <div class="clear">

    </div>

    <asp:HiddenField ID="HiddenField1" runat="server" Value="0" />

    <asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"

        OnClick="btnDelete_Click" />

    <br />

    (* Note: Message(s) will be automatically deleted after 30 days from the received

    date)

    <br />

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:omegalove
ID: 33613475
How can I merge the headers from the table into the following:
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">
    <tr>
        <th class="status" style="text-align: center">
            ?
        </th>
        <th class="cbox" style="text-align: center">
            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
        </th>
        <th class="sender">
            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="title">
            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="date">
            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="read">
            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>
        </th>
    </tr>
</table>
<asp:GridView ID="Inbox" runat="server" DataKeyNames="pmessageid" GridLines="None"

    OnPageIndexChanging="OnPaging" OnRowDataBound="Inbox_RowDataBound" Height="20px"

    HorizontalAlign="Center" VerticalAlign="Middle" AllowPaging="true" AllowSorting="true"

    EmptyDataText="No data available." PageSize="5" AutoGenerateColumns="false" CssClass="customers-grid">

    <AlternatingRowStyle Height="25px" HorizontalAlign="Center" BackColor="#D5E5FC" VerticalAlign="Middle" />

    <Columns>

        <asp:TemplateField HeaderText="Delete">

            <HeaderStyle CssClass="delete-member"></HeaderStyle>

            <ItemStyle CssClass="delete-member" Wrap="False"></ItemStyle>

            <HeaderTemplate>

                <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />

            </HeaderTemplate>

            <ItemTemplate>

                <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />

            </ItemTemplate>

        </asp:TemplateField>





        <asp:TemplateField>

            <HeaderStyle CssClass="from-pic"></HeaderStyle>

            <ItemStyle CssClass="from-pic" Wrap="False"></ItemStyle>

            <ItemTemplate>

                <br />

                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&PMessageID="+Eval("PMessageId")  + "&FromUsername=" + Eval("FromUser")  %>'>

                <asp:Image ID="MainPicID" BorderWidth="2" BorderColor="Silver" Style="vertical-align: middle"

                    class="srpic" runat="server" />

                 </asp:HyperLink><br />

                 <%#DataBinder.Eval(Container, "DataItem.FromUser")%>

                <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.FromProfileID") %>' />

            </ItemTemplate>

        </asp:TemplateField>



        <asp:TemplateField HeaderText="Subject" HeaderStyle-CssClass="subject" ItemStyle-CssClass="subject">

            <HeaderStyle CssClass="subject" />

            <ItemStyle CssClass="subject" />

            <ItemTemplate>

                <%--<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId") + "&FromUsername=" + Eval("FromUsername") %>' >--%>

                <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.IsRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%><%# DataBinder.Eval(Container, "DataItem.Subject") %>

                <%--</asp:HyperLink>--%>

            </ItemTemplate>

        </asp:TemplateField>

        

        <asp:TemplateField HeaderText="Message" HeaderStyle-CssClass="body" ItemStyle-CssClass="body">

            <HeaderStyle CssClass="body" />

            <ItemStyle CssClass="body" />

            <ItemTemplate>

                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px;">

                    <label>

                        <%#DataBinder.Eval(Container, "DataItem.Body")%>

                    </label>

                </div>

            </ItemTemplate>

        </asp:TemplateField>





        <asp:TemplateField HeaderText="Date" HeaderStyle-CssClass="date-sent" ItemStyle-CssClass="date-sent">

            <HeaderStyle CssClass="date-sent" />

            <ItemStyle CssClass="date-sent" />

            <ItemTemplate>

                <%# String.Format("{0:MMM-dd-yyyy HH:mm:ss tt}", ((System.Data.DataRowView)Container.DataItem)["Created"])%>

            </ItemTemplate>

        </asp:TemplateField>



        <asp:TemplateField HeaderText="Read" HeaderStyle-CssClass="read" ItemStyle-CssClass="read">

            <HeaderStyle CssClass="read" />

            <ItemStyle CssClass="read" />

            <ItemTemplate>

                <%--  <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>--%>

                <%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("IsRead")))%>

                <%--</asp:HyperLink>--%>

                <asp:Label runat="server" ID="UserPMessageID" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"UserPMessageID") %>' />

            </ItemTemplate>

        </asp:TemplateField>

    </Columns>

</asp:GridView>

<div class="clear">

</div>

<asp:HiddenField ID="hfCount" runat="server" Value="0" />

<asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"

    OnClick="btnDelete_Click" />

<br />

(* Note: Message(s) will be automatically deleted after 30 days from the received

date)

<br />

Open in new window

0
 
LVL 14

Accepted Solution

by:
Dhanasekaran Sengodan earned 500 total points
ID: 33615718
Here i added a sample code below
 

Aspx
---------

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Multiple or bulk Edit update and delete using checkbox in gridview </title>
    
     <script type="text/javascript" language="javascript">
        function DeleteConfirmation()
        {
          if (confirm("Are you sure, you want to delete selected records ?")==true)
            return true;
          else
            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<asp:GridView ID="GridView1" runat="server" 
              DataSourceID="SqlDataSource1" 
              AutoGenerateColumns="false" 
              CellPadding="2" ForeColor="#333333" 
              GridLines="Both" 
              DataKeyNames="ID" 
              OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="CheckAll">
<HeaderTemplate>
<asp:CheckBox ID="chkSelectAll" runat="server" 
              AutoPostBack="true" 
              OnCheckedChanged="chkSelectAll_CheckedChanged"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" 
              AutoPostBack="true" 
              OnCheckedChanged="chkSelect_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField DataField="ID" HeaderText="ID" 
                SortExpression="ID"/>
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<ItemTemplate>
<asp:TextBox ID="txtName" runat="server" 
             Text='<%# Bind("Name") %>' ForeColor="Blue" 
             BorderStyle="none" BorderWidth="0px" 
             ReadOnly="true" >
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Location" SortExpression="Location">
<ItemTemplate>
<asp:TextBox ID="txtLocation" runat="server" 
             Text='<%# Bind("Location") %>' 
             ForeColor="Blue" BorderStyle="none" BorderWidth="0px" 
             ReadOnly="true">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Name], [Location] FROM [Details]" 
DeleteCommand="DELETE FROM Details WHERE (ID = @ID)" 
UpdateCommand="UPDATE [Details] SET [Name] = @Name, 
               [Location] = @Location WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" />
</DeleteParameters>

<UpdateParameters>
<asp:Parameter Name="Name" />
<asp:Parameter Name="Location" />
<asp:Parameter Name="ID" />
</UpdateParameters>
</asp:SqlDataSource>

<asp:Button ID="btnUpdate" runat="server" 
            OnClick="btnUpdate_Click" Text="Update" />
<asp:Button ID="btnDelete" runat="server" 
            OnClick="btnDelete_Click" 
            Text="Delete" />
        <br />
        <br />
        <br />
        </div>
    </form>
</body>
</html>


cs
=====

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections.Specialized;
using System.Text;

public partial class _Default : System.Web.UI.Page 
{
    //Define global Connection String
    string strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        

    }
   
    private bool tableCopied = false;
    private DataTable originalTable;

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (!tableCopied)
            {
                originalTable = ((System.Data.DataRowView)e.Row.DataItem).Row.Table.Copy();
                ViewState["originalValues"] = originalTable;
                tableCopied = true;
            }
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        originalTable = (DataTable)ViewState["originalValues"];
        foreach (GridViewRow row in GridView1.Rows)
        if(IsRowModified(row))
        {
            GridView1.UpdateRow(row.RowIndex,false);
        }
        tableCopied = false;
        GridView1.DataBind();
    }

    protected bool IsRowModified(GridViewRow row)
    {
        int currentID;
        string currentName;
        string currentLocation;

        currentID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);

        currentName = ((TextBox)row.FindControl("txtName")).Text;
        currentLocation = ((TextBox)row.FindControl("txtLocation")).Text;

        System.Data.DataRow newRow = originalTable.Select(String.Format("ID = {0}", currentID))[0];

        if (!currentName.Equals(newRow["Name"].ToString())) { return true; }
        if (!currentLocation.Equals(newRow["Location"].ToString())) { return true; }

        return false;

    }
    protected void chkSelect_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkTest = (CheckBox)sender;
        GridViewRow grdRow = (GridViewRow)chkTest.NamingContainer;
        TextBox txtname = (TextBox)grdRow.FindControl("txtName");
        TextBox txtlocation = (TextBox)grdRow.FindControl("txtLocation");
        if (chkTest.Checked)
        {
            txtname.ReadOnly = false;
            txtlocation.ReadOnly = false;
            txtname.ForeColor = System.Drawing.Color.Black;
            txtlocation.ForeColor = System.Drawing.Color.Black;
        }
        else
        {
            txtname.ReadOnly = true;
            txtlocation.ReadOnly = true;
            txtname.ForeColor = System.Drawing.Color.Blue;
            txtlocation.ForeColor = System.Drawing.Color.Blue;
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        originalTable = (DataTable)ViewState["originalValues"];
        foreach (GridViewRow row in GridView1.Rows)
        {
            CheckBox chkDelete = (CheckBox)row.FindControl("chkSelect");
            if(chkDelete.Checked)
            {
                GridView1.DeleteRow(row.RowIndex);
            }
        }
        tableCopied = false;
        GridView1.DataBind();
    }
protected void chkSelectAll_CheckedChanged
                               (object sender, EventArgs e)
{
 CheckBox chkAll = 
    (CheckBox)GridView1.HeaderRow.FindControl("chkSelectAll");
 if (chkAll.Checked == true)
 {
   foreach (GridViewRow gvRow in GridView1.Rows)
   {
    CheckBox chkSel = 
         (CheckBox)gvRow.FindControl("chkSelect");
    chkSel.Checked = true;
    TextBox txtname = (TextBox)gvRow.FindControl("txtName");
    TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
    txtname.ReadOnly = false;
    txtlocation.ReadOnly = false;
    txtname.ForeColor = System.Drawing.Color.Black;
    txtlocation.ForeColor = System.Drawing.Color.Black;
   }
 }
 else
 {
  foreach (GridViewRow gvRow in GridView1.Rows)
  {
   CheckBox chkSel = (CheckBox)gvRow.FindControl("chkSelect");
   chkSel.Checked = false;
   TextBox txtname = (TextBox)gvRow.FindControl("txtName");
   TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
   txtname.ReadOnly = true;
   txtlocation.ReadOnly = true;
   txtname.ForeColor = System.Drawing.Color.Blue;
   txtlocation.ForeColor = System.Drawing.Color.Blue;
   }
  }
}

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        
        
    }
    
 }

Open in new window

0
 

Author Closing Comment

by:omegalove
ID: 33618855
k
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now