Sunasara this is the code:
<script type="text/javascript">
function ToggleRowColor(element) {
if (element.style.backgroundColor == 'cyan') {
element.style.backgroundColor = '#5691da';
element.style.cursor = 'hand';
element.style.textDecoration = 'none';
}
else {
element.style.backgroundColor = 'cyan';
element.style.cursor = 'hand';
element.style.textDecoration = 'underline';
}
}
</script>
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
</asp:scriptmanager>
<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
<contenttemplate>
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" datakeynames="Subj_id">
CssClass="cntrdatag" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True"
RowStyle-BackColor="#5691da" OnRowDataBound="GridView1_RowDataBound" OnRowUpdated="GridView1_RowUpdated"
OnRowUpdating="GridView1_RowUpdating" OnRowDeleted="GridView1_RowDeleted" Font-Size="Large"
Width="626px">
<columns>
<asp:commandfield showeditbutton="True" showdeletebutton="True" headerstyle-width="180">
ButtonType="Button" ShowCancelButton="true"></asp:commandfield>
<asp:boundfield datafield="subj_id" headerstyle-backcolor="#08346b" headertext="Subject-ID">
SortExpression="subj_id" HeaderStyle-Width="100" ReadOnly="true">
<HeaderStyle BackColor="#08346b" Width="100px" ForeColor="White" BorderColor="Black">
</HeaderStyle>
</asp:boundfield>
<asp:boundfield datafield="subj_name" headerstyle-backcolor="#08346b" headertext="Subject-Name">
SortExpression="subj_name" HeaderStyle-Width="200">
<HeaderStyle BackColor="#08346b" Width="200px" ForeColor="White" BorderColor="Black">
</HeaderStyle>
</asp:boundfield>
</columns>
<pagertemplate>
Current Page: <%=GridView1.PageIndex+1%>
Number of Pages:
<%=GridView1.PageCount %>
<br />
<asp:button id="btnFirst" runat="server" commandname="Page" cssclass="btn" commandargument="First">
Text="<<" />
<asp:button id="btnPrev" runat="server" commandname="Page" cssclass="btn" commandargument="Prev">
Text="<" />
<asp:button id="btnNext" runat="server" commandname="Page" cssclass="btn" commandargument="Next">
Text=">" />
<asp:button id="btnLast" runat="server" commandname="Page" cssclass="btn" commandargument="Last">
Text=">>" />
</asp:button></asp:button></asp:button></asp:button></pagertemplate>
<rowstyle backcolor="#5691da"></rowstyle>
</asp:gridview>
</contenttemplate>
</asp:updatepanel>
</script>
-----------------------------
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
if (e.Exception != null)
{
string x = e.Exception.Message; ;
Response.Write(@"<script language='javascript'>alert('" + x + "');</script>");
}
else
{
Response.Write(@"<script language='javascript'>alert('Updated Successfully');</script>");
}
}