Click here to Skip to main content
14,865,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<pre lang="c#"><pre lang="c#">
I Have Used A WebUserControl & Withen That Control I Used A Asp.Net GridView & That Gridview Is Present Withen a Update Panel.

That Usercontrol Is Used In Another Page

When i run that Page My Webusercontrol Apearing & In That I select A Row But Selected changed Index Is Not firing Here is My Code sample.

What I have tried:

ASP.NET
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ChannelWebUserControl.ascx.cs" Inherits="DEPWeb.ChannelWebUserControl" %>

<link href="../CSS/SiteFileGridMasterPage.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">

    function ColorChanged(sender) {
        //debugger;
        sender.get_element().style.backgroundColor = '#' + sender.get_selectedColor();
        sender.get_element().value = "0";
    }

    function ShowProgress() {
        setTimeout(function () {
            var modal = $('<div />');
            modal.addClass("modal");
            $('body').append(modal);
            var loading = $(".progress");
            loading.show();

            var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
            var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
            loading.css({ top: top, left: left });
        }, 200);
    }




</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="progress">
            <div style="margin-top: 100px">
                Loading... Please wait !
            </div>
            <img src="Images/progress.gif" alt="" style="text-align: center; position: center; margin-top: -160px" />
        </div>

        <div style="width: 100%;">
            <%--height: 60vh;--%>
            <div style="background-color: darkred; margin-right: 20px;">

                <asp:Panel ID="Panel1" runat="server" Width="100%" Height="100%">
                    <div style="width: 100%; height: 100%;">
                        <table style="width: 100%; height: 417px;">
                            <tr>
                                <td style="width: 40%; border: solid 1px black; background-color: AppWorkspace;">
                                    <asp:Panel ID="Panel2" runat="server" Width="100%" ScrollBars="Vertical" Height="100%">
                                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" OnSelectedIndexChanged="GridView1_SelectedIndexChanged2" SelectedIndex="1" OnRowCommand="GridView1_RowCommand">
                                            <Columns>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label1" runat="server" Text="A" ToolTip="Only channels flaged as Attached will be save or programmed"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_A1" runat="server" OnClick="btn_A1_Click" CausesValidation="False" Width="24px" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label2" runat="server" Text="Ch" ToolTip="Channel (this is read only)."></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="lbl_Ch1" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label3" runat="server" Text="Flat" ToolTip="Enter the Flat number."></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="lbl_Flat1" runat="server"></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label4" runat="server" Text="PPP" ToolTip="PSTN Patch Panel telephone number."></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:TextBox ID="txt_PPP1" runat="server"></asp:TextBox>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label5" runat="server" Text="Dr1" ToolTip="Door ID 0"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr1" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr1_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label6" runat="server" Text="Dr2" ToolTip="Door ID 1"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr2" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr2_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label7" runat="server" Text="Dr3" ToolTip="Door ID 2"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr3" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr3_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label8" runat="server" Text="Dr4" ToolTip="Door ID 3"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr4" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr4_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label9" runat="server" Text="Dr5" ToolTip="Door ID 4"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr5" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr5_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label10" runat="server" Text="Dr6" ToolTip="Door ID 5"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr6" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr6_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label11" runat="server" Text="Dr7" ToolTip="Door ID 6"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr7" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr7_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label12" runat="server" Text="Dr8" ToolTip="Door ID 7"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr8" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr8_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label13" runat="server" Text="Dr9" ToolTip="Door ID 8"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr9" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr9_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label14" runat="server" Text="Dr10" ToolTip="Door ID 9"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr10" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr10_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label15" runat="server" Text="Dr11" ToolTip="Door ID 10"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr11" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr11_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label16" runat="server" Text="Dr12" ToolTip="Door ID 11"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr12" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr12_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label17" runat="server" Text="Dr13" ToolTip="Door ID 12"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr13" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr13_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label18" runat="server" Text="Dr14" ToolTip="Door ID 13"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr14" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr14_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label19" runat="server" Text="Dr15" ToolTip="Door ID 14"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr15" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr15_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label20" runat="server" Text="Dr16" ToolTip="Door ID 15"></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_Dr16" runat="server" Text="Y" CausesValidation="False" OnClick="btn_Dr16_Click" Width="24px" OnClientClick="ShowProgress()" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <HeaderTemplate>
                                                        <asp:Label ID="Label21" runat="server" Text="DL" ToolTip="Download single channel without Tags."></asp:Label>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Button ID="btn_DL1" runat="server" Text="DL" CausesValidation="False" OnClick="btn_DL1_Click" Width="30px" />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                        <asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
                                    </asp:Panel>
                                </td>
                                <td style="width: 31%; border: solid 1px black; vertical-align: top;">
                                    <asp:Panel ID="Panel3" runat="server" Width="100%" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" ForeColor="White" HorizontalAlign="Center">
                                        <asp:Label ID="lbl_ChannelMsg1" runat="server" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Height="20px" Text="Hover mouse over the table headers for information." Width="290px" BackColor="Bisque" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" ForeColor="Black"></asp:Label>
                                        <br />
                                        <br />
                                        <asp:Label ID="lbl_Channelno" runat="server">Channel 1:</asp:Label>
                                        &nbsp;<br />
                                        <asp:Button ID="btn_DownloadChannel" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Style="text-align: center; margin-top: 10px" Text="Download Channel and Tags" ToolTip="Download a single channel to Site." Width="230px" OnClick="btn_DownloadChannel_Click" />
                                        <br />
                                        <asp:Label ID="lbl_ChannelMsg2" runat="server" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Style="text-align: center; margin-top: 10px" Height="51px" Text="This menu is used to assign physical Channels (where the handsets are wired) to Flat numbers (the digits you press on the Door Display Panel)." Width="290px" BackColor="Bisque" ForeColor="Black"></asp:Label><%--Height="60px"--%>
                                        <br />
                                        <br />
                                        <asp:Label ID="lbl_Flatno" runat="server">Tags for Flat 0001 (Ch 1)</asp:Label>
                                        <asp:Panel ID="Panel4" runat="server" HorizontalAlign="Center" Width="100%">
                                            <br />
                                            <table style="width: 90%; text-align: center;">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat9" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="1"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat9" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="1">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat9_ColorPickerExtender" runat="server" BehaviorID="txt_flat9_ColorPickerExtender" TargetControlID="txt_flat9" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat9" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat10" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="2"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat10" runat="server" BackColor="Red" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="2">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat10_ColorPickerExtender" runat="server" BehaviorID="txt_flat10_ColorPickerExtender" TargetControlID="txt_flat10" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat10" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat11" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="3"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat11" runat="server" BackColor="Green" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="3">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat11_ColorPickerExtender" runat="server" BehaviorID="txt_flat11_ColorPickerExtender" TargetControlID="txt_flat11" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat11" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat12" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="4"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat12" runat="server" BackColor="Blue" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="4">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat12_ColorPickerExtender" runat="server" BehaviorID="txt_flat12_ColorPickerExtender" TargetControlID="txt_flat12" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat12" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat13" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="5"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat13" runat="server" BackColor="#CC6600" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="5">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat13_ColorPickerExtender" runat="server" BehaviorID="txt_flat13_ColorPickerExtender" TargetControlID="txt_flat13" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat13" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat14" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="6"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat14" runat="server" BackColor="Orange" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="6">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat14_ColorPickerExtender" runat="server" BehaviorID="txt_flat14_ColorPickerExtender" TargetControlID="txt_flat14" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat14" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat15" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="7"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat15" runat="server" BackColor="#999999" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AutoPostBack="True" AccessKey="7">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat15_ColorPickerExtender" runat="server" BehaviorID="txt_flat15_ColorPickerExtender" TargetControlID="txt_flat15" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat15" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="lbl_Flat16" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="8"></asp:Label>
                                                        &nbsp;
                                                    <asp:TextBox ID="txt_flat16" runat="server" BackColor="Black" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" ForeColor="White" Width="135px" ToolTip="Click To Change Color" OnTextChanged="txt_flat16_TextChanged" AccessKey="8">0</asp:TextBox>
                                                        <ajaxToolkit:ColorPickerExtender ID="txt_flat16_ColorPickerExtender" runat="server" BehaviorID="txt_flat16_ColorPickerExtender" TargetControlID="txt_flat16" Enabled="true" OnClientColorSelectionChanged="ColorChanged" PopupPosition="TopRight" />
                                                        &nbsp;<asp:Button ID="btn_Flat16" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Text="DL" ToolTip="Download a single Tag." />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Button ID="btn_DownloadTags0" runat="server" Font-Names="Microsoft Sans Serif" Style="text-align: center; margin-top: 10px" Font-Size="8.25pt" Text="Download Tags" Width="150px" ToolTip="Download this channel's tags to Site." OnClick="btn_DownloadTags0_Click" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </asp:Panel>
                                        <asp:Button ID="btn_DownloadAll" runat="server" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Style="text-align: center; margin-top: 15px" Text="Download all Channels and Tags" ToolTip="Download all Attached Channels and Tags" Width="230px" OnClick="btn_DownloadAll_Click" />
                                    </asp:Panel>
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:Panel>
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>




using DEPBusiness;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DEPWeb
{
    public partial class ChannelWebUserControl : System.Web.UI.UserControl
    {
        int selectedCh = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //AddDefaultRecords();
            }
        }

        private void txt_flat9_OnKeyPress(string ctrlName, string args)
        {

        }

        public void AddDefaultRecords()
        {
            //creating dataTable   
            int i;
            DataTable dt = new DataTable();
            DataRow dr;
            dt.TableName = "Channels";
            dt.Columns.Add(new DataColumn("A", typeof(string)));
            dt.Columns.Add(new DataColumn("Ch", typeof(string)));
            dt.Columns.Add(new DataColumn("Flat", typeof(string)));
            dt.Columns.Add(new DataColumn("PPP", typeof(string)));
            for (i = 0; i < 256; i++)
            {
                dr = dt.NewRow();
                dt.Rows.Add(dr);
            }
            //saving databale into viewstate   
            ViewState["channels"] = dt;
            //bind Gridview  
            GridView1.DataSource = dt;
            GridView1.DataBind();
            GridView1.SelectedIndex = 0;
        }

        public void AddDefaultRecords(GridView objGridView)
        {
            //creating dataTable   
            int i;
            DataTable dt = new DataTable();
            DataRow dr;
            dt.TableName = "Channels";
            dt.Columns.Add(new DataColumn("A", typeof(string)));
            dt.Columns.Add(new DataColumn("Ch", typeof(string)));
            dt.Columns.Add(new DataColumn("Flat", typeof(string)));
            dt.Columns.Add(new DataColumn("PPP", typeof(string)));
            for (i = 0; i < 256; i++)
            {
                dr = dt.NewRow();
                dt.Rows.Add(dr);
            }
            //saving databale into viewstate   
            ViewState["channels"] = dt;
            //bind Gridview  
            objGridView.DataSource = dt;
            objGridView.DataBind();
            objGridView.SelectedIndex = 0;
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    int rowno = e.Row.RowIndex;
                    Label colCh = e.Row.FindControl("lbl_Ch1") as Label;
                    Label colFlat = e.Row.FindControl("lbl_Flat1") as Label;
                    colCh.Text = Convert.ToString(rowno + 1);
                    colFlat.Text = Convert.ToString(rowno + 1).PadLeft(4, '0');
                    e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex);
                }
            }
            catch (Exception ex)
            {
                //catching no error for now
            }

        }

        protected void btn_A1_Click(object sender, EventArgs e)
        {
            Button btnA1 = sender as Button;
            if (btnA1.Text == "")
            {
                btnA1.Text = "A";
            }
            else
            {
                btnA1.Text = "";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;

            int index = gvRow.RowIndex;


            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
        }

        #region ---  Door Section  ---
        protected void btn_Dr1_Click(object sender, EventArgs e)
        {
            Button btnDr1 = sender as Button;
            if (btnDr1.Text == "Y")
            {
                btnDr1.Text = "";
            }
            else
            {
                btnDr1.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);


            //SiteFile objSiteFile = new SiteFile();
            //objSiteFile.refreshTags();
            selectedCh = index;

            // refreshTags();

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();

        }

        private void refreshTags()
        {
            txt_flat9.Text = cSiteData.stCh[selectedCh].tag[0].ToString();

            txt_flat10.Text = cSiteData.stCh[selectedCh].tag[1].ToString();

            txt_flat11.Text = cSiteData.stCh[selectedCh].tag[2].ToString();

            txt_flat12.Text = cSiteData.stCh[selectedCh].tag[3].ToString();

            txt_flat13.Text = cSiteData.stCh[selectedCh].tag[4].ToString();

            txt_flat14.Text = cSiteData.stCh[selectedCh].tag[5].ToString();

            txt_flat15.Text = cSiteData.stCh[selectedCh].tag[6].ToString();

            txt_flat16.Text = cSiteData.stCh[selectedCh].tag[7].ToString();

            txt_flat9.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[0]);

            txt_flat10.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[1]);

            txt_flat11.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[2]);

            txt_flat12.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[3]);

            txt_flat13.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[4]);

            txt_flat14.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[5]);

            txt_flat15.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[6]);

            txt_flat16.BackColor = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[7]);

            txt_flat9.ForeColor = getTagForeground(0);

            txt_flat10.ForeColor = getTagForeground(1);

            txt_flat11.ForeColor = getTagForeground(2);

            txt_flat12.ForeColor = getTagForeground(3);

            txt_flat13.ForeColor = getTagForeground(4);

            txt_flat14.ForeColor = getTagForeground(5);

            txt_flat15.ForeColor = getTagForeground(6);

            txt_flat16.ForeColor = getTagForeground(7);
        }

        private Color getTagForeground(int tag)
        {
            int i;
            Color bkg = Color.FromArgb((int)cSiteData.stCh[selectedCh].tagColor[tag]);
            Color frg;
            i = bkg.R + bkg.B + bkg.G;
            if (i > 0x17f) frg = Color.Black;
            else frg = Color.White;
            return (frg);
        }

        protected void btn_Dr2_Click(object sender, EventArgs e)
        {
            Button btnDr2 = sender as Button;
            if (btnDr2.Text == "Y")
            {
                btnDr2.Text = "";
            }
            else
            {
                btnDr2.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();

        }

        protected void btn_Dr3_Click(object sender, EventArgs e)
        {
            Button btnDr3 = sender as Button;
            if (btnDr3.Text == "Y")
            {
                btnDr3.Text = "";
            }
            else
            {
                btnDr3.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr4_Click(object sender, EventArgs e)
        {
            Button btnDr4 = sender as Button;
            if (btnDr4.Text == "Y")
            {
                btnDr4.Text = "";
            }
            else
            {
                btnDr4.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr5_Click(object sender, EventArgs e)
        {
            Button btnDr5 = sender as Button;
            if (btnDr5.Text == "Y")
            {
                btnDr5.Text = "";
            }
            else
            {
                btnDr5.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr6_Click(object sender, EventArgs e)
        {
            Button btnDr6 = sender as Button;
            if (btnDr6.Text == "Y")
            {
                btnDr6.Text = "";
            }
            else
            {
                btnDr6.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr7_Click(object sender, EventArgs e)
        {
            Button btnDr7 = sender as Button;
            if (btnDr7.Text == "Y")
            {
                btnDr7.Text = "";
            }
            else
            {
                btnDr7.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr8_Click(object sender, EventArgs e)
        {
            Button btnDr8 = sender as Button;
            if (btnDr8.Text == "Y")
            {
                btnDr8.Text = "";
            }
            else
            {
                btnDr8.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr9_Click(object sender, EventArgs e)
        {
            Button btnDr9 = sender as Button;
            if (btnDr9.Text == "Y")
            {
                btnDr9.Text = "";
            }
            else
            {
                btnDr9.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr10_Click(object sender, EventArgs e)
        {
            Button btnDr10 = sender as Button;
            if (btnDr10.Text == "Y")
            {
                btnDr10.Text = "";
            }
            else
            {
                btnDr10.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr11_Click(object sender, EventArgs e)
        {
            Button btnDr11 = sender as Button;
            if (btnDr11.Text == "Y")
            {
                btnDr11.Text = "";
            }
            else
            {
                btnDr11.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr12_Click(object sender, EventArgs e)
        {
            Button btnDr12 = sender as Button;
            if (btnDr12.Text == "Y")
            {
                btnDr12.Text = "";
            }
            else
            {
                btnDr12.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr13_Click(object sender, EventArgs e)
        {
            Button btnDr13 = sender as Button;
            if (btnDr13.Text == "Y")
            {
                btnDr13.Text = "";
            }
            else
            {
                btnDr13.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr14_Click(object sender, EventArgs e)
        {
            Button btnDr14 = sender as Button;
            if (btnDr14.Text == "Y")
            {
                btnDr14.Text = "";
            }
            else
            {
                btnDr14.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr15_Click(object sender, EventArgs e)
        {
            Button btnDr15 = sender as Button;
            if (btnDr15.Text == "Y")
            {
                btnDr15.Text = "";
            }
            else
            {
                btnDr15.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }

        protected void btn_Dr16_Click(object sender, EventArgs e)
        {
            Button btnDr16 = sender as Button;
            if (btnDr16.Text == "Y")
            {
                btnDr16.Text = "";
            }
            else
            {
                btnDr16.Text = "Y";
            }

            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            (gvRow.FindControl("btn_A1") as Button).Text = "A";
            int index = gvRow.RowIndex;

            cSiteData.stCh[index].EN = true;//Added By Arya In Place Of Grid Event Like Value Changed & Content Clicked etc...

            int drGrp = 0;
            for (int i = 4; i <= 19; i++)
            {
                drGrp >>= 1;
                if ((string)((GridView1.Rows[index].Cells[i].Controls[1] as Button).Text) == "Y")
                    drGrp |= 0x8000;
            }
            char[] s = "0000".ToArray();
            s[3] = cFunc.HexAsc(drGrp & 0x000f);
            s[2] = cFunc.HexAsc((drGrp >> 4) & 0x000f);
            s[1] = cFunc.HexAsc((drGrp >> 8) & 0x000f);
            s[0] = cFunc.HexAsc((drGrp >> 12) & 0x000f);
            cSiteData.stCh[index].drGroup = new string(s);

            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
            TextBox txtppp = (TextBox)gvRow.FindControl("txt_PPP1");
            cSiteData.stCh[index].ppp = txtppp.Text.ToString();
        }
        #endregion

        protected void btn_DL1_Click(object sender, EventArgs e)
        {
            GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
            int index = gvRow.RowIndex;
            this.lbl_Channelno.Text = "Channel " + (index + 1).ToString() + ": ";
            this.lbl_Flatno.Text = "Tags for Flat " + (index + 1).ToString().PadLeft(4, '0') + " (Ch " + (index + 1).ToString() + ")";
        }

        //protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    foreach (GridViewRow row in GridView1.Rows)
        //    {
        //        if (row.RowIndex == GridView1.SelectedIndex)
        //        {
        //            this.lbl_Channelno.Text = "Channel " + (row.RowIndex + 1).ToString() + ": ";
        //            this.lbl_Flatno.Text = "Tags for Flat " + (row.RowIndex + 1).ToString().PadLeft(4, '0') + " (Ch " + (row.RowIndex + 1).ToString() + ")";
        //        }
        //    }


        //}

        protected void txt_flat16_TextChanged(object sender, EventArgs e)
        {
            TextBox b = (TextBox)sender;
            int t = (int)Convert.ToChar(b.AccessKey) & 0x0f;
            t -= 1;
            int tagCode = cFunc.StrInt(b.Text);
            int tagOld = (int)cSiteData.stCh[selectedCh].tag[t];
            cSiteData.stCh[selectedCh].tag[t] = tagCode;
            if (cSiteData.stCh[selectedCh].tag[t] > 0)
            {
                cSiteData.stCh[selectedCh].EN = true;
                //GridView1.Rows[selectedCh].Cells["Attached"].Value = "A";

                //for (int ch = 0; ch <= 255; ++ch)
                //{
                //    for (int tg = 0; tg <= 7; ++tg)
                //    {       // remove any others with same code (this also done at ACM when tap programmed).
                //        if (cSiteData.stCh[ch].tag[tg] == tagCode)
                //        {               // same code
                //            if (ch != selectedCh || (ch == selectedCh && tg != t))
                //            {       // not selected tag
                //                //var result = MessageBox.Show(" Tag assigned to Channel " + (ch + 1).ToString() + " (" + (tg + 1).ToString() + "). \n" +
                //                //                        " Do you want to move it to Channel " + (selectedCh + 1).ToString() + " (" + (t + 1).ToString() + ") ?",
                //                //                        " DUPLICATED TAG", MessageBoxButtons.YesNo);
                //                //if (result == DialogResult.Yes)
                //                //string winFeatures = "Tag assigned to Channel " + (ch + 1).ToString() + "(" + (tg + 1).ToString() + "). \n" +
                //                //                       " Do you want to move it to Channel " + (selectedCh + 1).ToString() + " (" + (t + 1).ToString() + ") ?"+","+
                //                //                       " DUPLICATED TAG";
                //                //ScriptManager.RegisterStartupScript(this.GetType(), "newWindow", string.Format("<script type='text/javascript'>var popup=window.open('{0}', 'yourWin', '{1}'); popup.focus();</script>", url, winFeatures));
                //                cSiteData.stCh[ch].tag[tg] = 0;     // delete tag 
                //                else
                //                    cSiteData.stCh[selectedCh].tag[t] = tagOld; // restore previous tag
                //                refresh();
                //            }
                //        }
                //    }
                //}
            }
        }

        protected void btn_DownloadChannel_Click(object sender, EventArgs e)
        {
            cSerial.UploadChannelAndTags(selectedCh);
        }

        protected void btn_DownloadTags0_Click(object sender, EventArgs e)
        {
            bool ERR = true;
            if (cSerial.txAreYouThere() > 0)
            {
                ERR = false;
                for (int t = 1; t <= 8 && !ERR; ++t)
                    if (cSerial.putTag(selectedCh, t) < 0) ERR = true;
            }
        }

        protected void btn_DownloadAll_Click(object sender, EventArgs e)
        {
            bool ERR = cSerial.UploadAllChannels();
        }

       
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }

        protected void GridView1_SelectedIndexChanged2(object sender, EventArgs e)
        {

        }
    }
}
Posted
Updated 20-May-16 0:04am
v3
Comments
CHill60 20-May-16 4:21am
   
There is no point in including ALL of your code behind - edit your question to remove the stuff that is not relevant. Most people will take one look at all that unformatted code and just move on to the next question

1 solution

Hi,
No need to put the whole code here, however according to your question, the controls selectedindexchanged event is not firing.
This issue must be of because Autopostback property of control is false
set it to true.
C#
<asp:button autopostback="true" xmlns:asp="#unknown"> </asp:button>
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900