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 LenkaPosted Oct 1, 2013, 3:40 AM
Sanjay KumarPosted Oct 1, 2013, 3:30 AM
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 LenkaPosted Oct 1, 2013, 3:10 AM
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 KumarPosted Oct 1, 2013, 2:43 AM
Sanjeeb LenkaPosted Oct 1, 2013, 2:26 AM
in Button click just update the value in db. by using the datakey Userid.
Sanjay KumarPosted Oct 1, 2013, 2:22 AM
Ex: Active button =1
Deactive button=0
Sanjeeb LenkaPosted Oct 1, 2013, 2:10 AM
plz provide clear details what actually your requirement.