Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:GridView ID="grdNotiSearch" runat="server" Width="100%"
                                 PageSize="10" AutoGenerateColumns="false"
                                 DataKeyNames="Upload_Code,UPLOAD_TYPE,UPLOAD_DESC,MESSAGE,DISPL_FLASH,DISPL_HOME,LINK_DISPLAY,
                                 NOTI_CODE,NOTI_NUM,NOTI_DATE"
                                 OnRowCreated="grdNotiSearch_RowCreated"
                                 OnRowCommand="grdNotiSearch_RowCommand"
                                 OnPageIndexChanging="grdNotiSearch_PageIndexChanging"
                                 EmptyDataText="Records Not Found..!"
                                 onselectedindexchanged="grdNotiSearch_SelectedIndexChanged">
                                 <Columns>
                                 <asp:BoundField DataField="NOTI_NUM" HeaderText="Noti Code" Visible="false" />
                                    <asp:BoundField DataField="Noti_Num" HeaderText="Notification">
                                        <ItemStyle HorizontalAlign="Left" Width="25%" CssClass="GridViewItemStyle" />
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Noti_Date" HeaderText="Date">
                                        <ItemStyle HorizontalAlign="Center" Width="10%" />
                                        <HeaderStyle HorizontalAlign="Center"/>
                                    </asp:BoundField>
                                    <asp:BoundField DataField="UPLOADS" HeaderText="Result Description">
                                        <ItemStyle HorizontalAlign="left" Width="55%" />
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Act_Stat" HeaderText="Active">
                                        <ItemStyle HorizontalAlign="Center"  Width="10%" />
                                        <HeaderStyle HorizontalAlign="Center" />
                                   </asp:BoundField>
                                       <asp:TemplateField>
                                      <ItemTemplate>
                                       <asp:Button ID="btnEdit" runat="server" Width="45px" Text="EDIT" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"  CommandName="Edit" />
                                      </ItemTemplate>
                                    </asp:TemplateField>
                                     <asp:TemplateField>
                                      <ItemTemplate>
                                       <asp:Button ID="btnClick" runat="server" Width="45px" Text="TEST" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="Test" />
                                      </ItemTemplate>
                                    </asp:TemplateField>
                                     <asp:BoundField >
                                        <ItemStyle HorizontalAlign="Center"  Width="3%" />
                                        <HeaderStyle HorizontalAlign="Center" />
                                   </asp:BoundField>
                                </Columns>
                                <HeaderStyle CssClass="GridViewHeaderStyle" />
                                <RowStyle CssClass="GridViewRowStyle" />
                                <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                                <PagerStyle CssClass="GridViewPagerStyle" />
                                <EmptyDataRowStyle CssClass="GridViewEmptyRowStyle" />
                                <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                           </asp:GridView>


[EDIT - CHill60 - OP Code from comment]
C#
protected void grdNotiSearch_RowCommand(object sender, GridViewCommandEventArgs e)
{
    try
    {
        if (e.CommandName == "Edit")
        {
            int index = Convert.ToInt32(e.CommandArgument.ToString());
            string noticodes = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();
            string uploadcodes = grdNotiSearch.DataKeys[index]["Upload_Code"].ToString();
            string UploadType = grdNotiSearch.DataKeys[index]["UPLOAD_TYPE"].ToString();

            lblMessage.Text = "";
            string encryptedString = Encrypt("" + noticodes + "");
            string encryptedString1 = Encrypt("" + uploadcodes + "");

            lblMessage.Text = "";
            encryptedString = Encrypt("" + noticodes + "");
            encryptedString1 = Encrypt("" + uploadcodes + "");

            Response.Redirect("ResultDBSearchNew.aspx?" + encryptedString + "," + encryptedString1 + "");
        }

        if (e.CommandName == "Test")
        {
            int index = Convert.ToInt32(e.CommandArgument.ToString());
            string noti = Convert.ToString(e.CommandArgument.ToString());


            int rowIndex = int.Parse(e.CommandArgument.ToString());
            string val = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();

            string noticodes = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();
            string uploadcodes = grdNotiSearch.DataKeys[index]["Upload_Code"].ToString();
            string UploadType = grdNotiSearch.DataKeys[index]["UPLOAD_TYPE"].ToString();
            // string notis = grdNotiSearch.SelectedDataKey["NOTI_CODE"].ToString();

            lblMessage.Text = "";
            string encryptedString = Encrypt("" + noticodes + "");
            string encryptedString1 = Encrypt("" + uploadcodes + "");

            if (UploadType == "4")
            {
                Response.Redirect("~/Modules/TestPages/ApplicationStatus/ApplicationIndex.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "5")
            {
                Response.Redirect("~/Modules/TestPages/WrittenTestResult/WrittenTestResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "6")
            {
                Response.Redirect("~/Modules/ApplicationStatus/PETResult/PETResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "7")
            {
                Response.Redirect("~/Modules/TestPages/DocVerifySchedule/DocumentVerifyResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "8")
            {
                Response.Redirect("~/Modules/TestPages/Panel/PanelResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "9")
            {
                Response.Redirect("~/Modules/TestPages/ExServicemen/ExServicemenDVStatusResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "10")
            {
                Response.Redirect("~/Modules/TestPages/ExServicemen/PanelExServiceResult.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
            else if (UploadType == "11")
            {
                Response.Redirect("~/Modules/TestPages/CallLetter/AppDisplayTest.aspx?" + encryptedString + "," + encryptedString1 + "");
            }
        }
    }
    catch (Exception ex)
    {
        lblMessage.Text = ex.Message;
    }
}
Posted
Updated 4-Jul-14 1:53am
v2
Comments
kedar001 4-Jul-14 7:24am    
also post your code for grdNotiSearch_RowCreated ,grdNotiSearch_RowCommand
Khan Sameer 4-Jul-14 7:30am    
That is of no use therefore i didn't Post !!!!!
CHill60 4-Jul-14 7:34am    
Er... the RowCommand function might be the root of your problem!
Khan Sameer 4-Jul-14 7:36am    
protected void grdNotiSearch_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument.ToString());
string noticodes = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();
string uploadcodes = grdNotiSearch.DataKeys[index]["Upload_Code"].ToString();
string UploadType = grdNotiSearch.DataKeys[index]["UPLOAD_TYPE"].ToString();

lblMessage.Text = "";
string encryptedString = Encrypt("" + noticodes + "");
string encryptedString1 = Encrypt("" + uploadcodes + "");

lblMessage.Text = "";
encryptedString = Encrypt("" + noticodes + "");
encryptedString1 = Encrypt("" + uploadcodes + "");

Response.Redirect("ResultDBSearchNew.aspx?" + encryptedString + "," + encryptedString1 + "");

}

if (e.CommandName == "Test")
{
int index = Convert.ToInt32(e.CommandArgument.ToString());
string noti = Convert.ToString(e.CommandArgument.ToString());


int rowIndex = int.Parse(e.CommandArgument.ToString());
string val = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();

string noticodes = grdNotiSearch.DataKeys[index]["NOTI_CODE"].ToString();
string uploadcodes = grdNotiSearch.DataKeys[index]["Upload_Code"].ToString();
string UploadType = grdNotiSearch.DataKeys[index]["UPLOAD_TYPE"].ToString();
// string notis = grdNotiSearch.SelectedDataKey["NOTI_CODE"].ToString();

lblMessage.Text = "";
string encryptedString = Encrypt("" + noticodes + "");
string encryptedString1 = Encrypt("" + uploadcodes + "");

if (UploadType == "4")
{
Response.Redirect("~/Modules/TestPages/ApplicationStatus/ApplicationIndex.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "5")
{
Response.Redirect("~/Modules/TestPages/WrittenTestResult/WrittenTestResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "6")
{
Response.Redirect("~/Modules/ApplicationStatus/PETResult/PETResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "7")
{
Response.Redirect("~/Modules/TestPages/DocVerifySchedule/DocumentVerifyResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "8")
{
Response.Redirect("~/Modules/TestPages/Panel/PanelResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "9")
{
Response.Redirect("~/Modules/TestPages/ExServicemen/ExServicemenDVStatusResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "10")
{
Response.Redirect("~/Modules/TestPages/ExServicemen/PanelExServiceResult.aspx?" + encryptedString + "," + encryptedString1 + "");
}
else if (UploadType == "11")
{
Response.Redirect("~/Modules/TestPages/CallLetter/AppDisplayTest.aspx?" + encryptedString + "," + encryptedString1 + "");
}

}
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}

}
kedar001 4-Jul-14 7:37am    
what error you are getting on "Test"

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



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