Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to fix the following from gridview to repeater.

Posted on 2010-09-06
6
Medium Priority
?
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 60

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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