i have a one grid and in that i am taking two template feild and in that asp buttonn. now i am changing that button text and css class on that clientclick in javascript. i have another button outside that grid and on that click event i want the changing taxt of grid view button but i can not get.
this is my grid view and out side button
<div class="box-body-outer">
<div class="padding_bottomtop_5px header_btn_div padding_left_20px">
<asp:Button ID="btnSave" align="right" class="btnStyle-Success" runat="server" Text="Save"
OnClick="btnSave_Click" OnClientClick="ClientValidate();" />
</div>
<div id="div_all_EmailSMS" runat="server" class="box-body">
<div class="table-responsive">
<asp:GridView ID="dgv_EmailSmsSetting" runat="server" CssClass="table table-bordered table-striped"
AutoGenerateColumns="False" CellPadding="5" BorderStyle="Solid"
BorderWidth="3px" CellSpacing="10" >
<Columns>
<asp:TemplateField HeaderText="Send Email">
<ItemTemplate>
<asp:Button ID="btnEmail" runat="server" OnClientClick="return Alter(this.id);" CssClass='<%#Eval("SendEmail").ToString()=="True" ? "btn btn-success" : "btn btn-danger" %>' Text='<%#Eval("SendEmail").ToString()=="True" ? "Active" : "In Active" %>' />
<asp:HiddenField runat="server" ID="hidemail" Value='<%#Eval("SendEmail") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Send SMS">
<ItemTemplate>
<asp:Button ID="btnSMS" runat="server" OnClientClick="return Alter(this.id);" CssClass='<%#Eval("SendSMS").ToString()=="True" ? "btn btn-success" : "btn btn-danger" %>' Text='<%#Eval("SendSMS").ToString()=="True" ? "Active" : "In Active" %>' />
<asp:HiddenField runat="server" ID="hidesms" Value='<%#Eval("SendSMS") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
this is my javascript function that changes text and css of inside button
<script type="text/javascript">
function Alter(id)
{
var btn = document.getElementById(id).value;
if (btn == "In Active") {
document.getElementById(id).className = "btn btn-success";
document.getElementById(id).value = "Active";
}
else {
document.getElementById(id).className = "btn btn-danger";
document.getElementById(id).value = "In Active";
}
return false;
}
</script>
and this is my btnsave onclick method
protected void btnSave_Click(object sender, EventArgs e)
{
bool email=false, sms=false;
Button btnEmail = (Button)dgv_EmailSmsSetting.Rows[0].Cells[0].FindControl("btnEmail");
Button btnsms = (Button)dgv_EmailSmsSetting.Rows[0].Cells[1].FindControl("btnSMS");
string str = dgv_EmailSmsSetting.Rows[0].Cells[0].Text;
if (Request.Form[btnsms.UniqueID] == "Active")
sms = true;
if (Request.Form[btnEmail.UniqueID] == "Active")
email = true;
objSchoolModel.UpdateEmailSmsSetting(email,sms,Convert.ToInt32(Session["InstituteID"]));
}
i want updated text from both button but i can't get. getting first bind text