Hell Guyzz..!
i m here again to take your support hope u will solve it as soon as possible and i will be your thankfull
on click active button it should be changed into inactive in while click on in active it should be changed again into active
here you go my gridview design and code:
Back
ID | Cetagory | Name | Color | Price | Click_it | Click_It | Click_It | Status |
43 |
0 |
toshiba |
kala |
221 |
Delet |
Edit |
update |
Active Inactive |
45 |
0 |
mui9 |
yelloww1 |
190001 |
Delet |
Edit |
update |
Active Inactive |
47 |
1 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
49 |
1 |
blackberry |
totally black |
72000 |
Delet |
Edit |
update |
Active Inactive |
50 |
1 |
wwwww |
wwwww |
2222222 |
Delet |
Edit |
update |
Active Inactive |
52 |
2 |
samsung |
black |
2000 |
Delet |
Edit |
update |
Active Inactive |
53 |
3 |
hp |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
69 |
1 |
samsung |
white |
300000 |
Delet |
Edit |
update |
Active Inactive |
93 |
1 |
Dsk |
Black |
78888 |
Delet |
Edit |
update |
Active Inactive |
94 |
1 |
i3computer |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
95 |
1 |
hp |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
96 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
97 |
2 |
hp |
white |
22000 |
Delet |
Edit |
update |
Active Inactive |
98 |
1 |
samsung |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
99 |
1 |
samsung |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
100 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
105 |
1 |
hp |
black |
12000 |
Delet |
Edit |
update |
Active Inactive |
106 |
3 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
107 |
1 |
mi9 |
white |
32000 |
Delet |
Edit |
update |
Active Inactive |
108 |
3 |
mi99 |
mehroom |
20000 |
Delet |
Edit |
update |
Active Inactive |
109 |
3 |
i3computer |
white |
16000 |
Delet |
Edit |
update |
Active Inactive |
110 |
1 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
111 |
1 |
samsung |
Blue |
12000 |
Delet |
Edit |
update |
Active Inactive |
112 |
2 |
i3computer |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
114 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
115 |
2 |
i3computer |
black |
444500 |
Delet |
Edit |
update |
Active Inactive |
116 |
1 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
117 |
1 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
118 |
2 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
119 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
120 |
5 |
myproject |
nila |
19191919 |
Delet |
Edit |
update |
Active Inactive |
121 |
1 |
samsung |
hala |
2323 |
Delet |
Edit |
update |
Active Inactive |
122 |
1 |
samsung |
hala |
2323 |
Delet |
Edit |
update |
Active Inactive |
123 |
2 |
i9 |
koibhi |
3214 |
Delet |
Edit |
update |
Active Inactive |
124 |
1 |
hp |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
125 |
3 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
126 |
1 |
hp |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
127 |
2 |
hp |
fvrt |
16000 |
Delet |
Edit |
update |
Active Inactive |
128 |
2 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
129 |
2 |
hp |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
130 |
2 |
koibhi |
koibhi |
1234 |
Delet |
Edit |
update |
Active Inactive |
131 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
132 |
2 |
i3computer |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
133 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
134 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
135 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
136 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
137 |
1 |
hp |
Blue |
32000 |
Delet |
Edit |
update |
Active Inactive |
138 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
139 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
140 |
1 |
samsung |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
141 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
142 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
143 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
144 |
2 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
145 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
146 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
147 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
148 |
1 |
samsung |
Blue |
12000 |
Delet |
Edit |
update |
Active Inactive |
149 |
1 |
samsung |
Blue |
32000 |
Delet |
Edit |
update |
Active Inactive |
150 |
1 |
hp |
Blue |
32000 |
Delet |
Edit |
update |
Active Inactive |
151 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
152 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
153 |
1 |
samsung |
black |
32000 |
Delet |
Edit |
update |
Active Inactive |
154 |
3 |
hp |
Blue |
16000 |
Delet |
Edit |
update |
Active Inactive |
155 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
156 |
2 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
157 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
158 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
159 |
2 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
160 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
161 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
162 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
163 |
2 |
md |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
164 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
165 |
1 |
samsung |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
166 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
167 |
1 |
hp |
black |
16000 |
Delet |
Edit |
update |
Active Inactive |
169 |
|
|
|
|
Delet |
Edit |
update |
Active Inactive |
170 |
|
|
|
|
Delet |
Edit |
update |
Active Inactive |
aspx code:
- <asp:GridView ID="grd" runat="server" AutoGenerateColumns="false" OnRowEditing="grd_RowEditing" OnRowUpdating="grd_RowUpdating" OnRowCommand="grd_RowCommand" OnSelectedIndexChanged="grd_SelectedIndexChanged">
- <Columns>
- <asp:BoundField DataField="pid" HeaderText="ID" />
- <asp:TemplateField HeaderText="Cetagory">
- <ItemTemplate>
- <%#Eval("category") %>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Name">
- <ItemTemplate>
- <%#Eval("name") %>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Color">
- <ItemTemplate>
- <%#Eval("color") %>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Price">
- <ItemTemplate>
- <%#Eval("price") %>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Click_it">
- <ItemTemplate>
- <asp:LinkButton ID="lnkbtndelt" runat="server" CommandName="delt" CommandArgument='<%#Eval("pid") %>' Text="Delet" />
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Click_It">
- <ItemTemplate>
- <asp:LinkButton ID="lnkbtnedit" runat="server" CommandName="edt" CommandArgument='<%#Eval("pid") %>' Text="Edit" OnClick="btnedit_Click" />
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Click_It">
- <ItemTemplate>
- <asp:LinkButton ID="lnkbtnupd" runat="server" CommandName="upd" CommandArgument='<%#Eval("pid") %>' Text="update" OnClick="lnkbtnupd_Click" />
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Status">
- <ItemTemplate>
- <asp:LinkButton ID="lbtactive" runat="server" Text="Active" OnClick="lbtactive_Click"></asp:LinkButton>
- <asp:LinkButton ID="ibinactive" runat="server" Text="Inactive" OnClick="ibinactive_Click"></asp:LinkButton>
- </ItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
cs code:
- private void active(string val, string code)
- {
- SqlCommand cmd = new SqlCommand("update products set status = '" + val + "' where pid = '" + code + "'", con);
- con.Open();
- cmd.CommandType = CommandType.Text;
- cmd.ExecuteNonQuery();
- con.Close();
- }
- protected void lbtactive_Click(object sender, EventArgs e)
- {
- active("1", grd.Rows[((GridViewRow)((sender as Control)).NamingContainer).RowIndex].Cells[0].Text);
- }
- protected void ibinactive_Click(object sender, EventArgs e)
- {
- int Index = ((GridViewRow)((sender as Control)).NamingContainer).RowIndex;
- active("0", grd.Rows[Index].Cells[0].Text);
- }
- }
plz rply as soon as possible
thank you