Hi
how to active & deactive two Button and Button_Click update value database in GridView
<asp:GridView ID="grdUserList" runat="server" AutoGenerateColumns="False" DataKeyNames="UserID" OnRowCommand="grdUserList_RowCommand" >
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" InsertVisible="False" ReadOnly="True" SortExpression="UserID" />
<asp:TemplateField HeaderText="CurrentStatus">
<ItemTemplate>
<table>
<tr>
<td align="center" style="width: 78px">
<asp:Button ID="Button2" runat="server" Text="Active" />td>
<td align="center" style="width: 76px">
<asp:Button ID="Button3" runat="server" Text="Deactive" />td>
tr>
table>
ItemTemplate>
asp:TemplateField>
Columns>
asp:GridView>
Loading


Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 30, 2013, 10:10 PM EDT
plz provide clear details what actually your requirement.
Sanjay KumarRank #561 · 4.3K reputationPosted Sep 30, 2013, 10:22 PM EDT
Ex: Active button =1
Deactive button=0
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 30, 2013, 10:26 PM EDT
in Button click just update the value in db. by using the datakey Userid.
Sanjay KumarRank #561 · 4.3K reputationPosted Sep 30, 2013, 10:43 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 30, 2013, 11:10 PM EDT
int code = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Values[0].ToString());
try like this. if you are not getting plz share your code aspx and cs i will do the modification.
Sanjay KumarRank #561 · 4.3K reputationPosted Sep 30, 2013, 11:30 PM EDT
protected void grdUserList_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;
int code = Convert.ToInt32(grdUserList.DataKeys[row.RowIndex].Values[0].ToString());
}
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 30, 2013, 11:40 PM EDT