If user click on continue button next time cannot press button only click on first time
In GridView some button like select if user click on select button next time he cannot select button means he also called as disable
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Height="181px"
Width="1300px" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black">
<Columns>
<asp:TemplateField HeaderText="No.">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="id" HeaderText="id" />
<asp:BoundField DataField="first_name" HeaderText="First Name" />
<asp:BoundField DataField="last_name" HeaderText="Last Name" />
<asp:BoundField DataField="pick_up" HeaderText="Pick UP" />
<asp:BoundField DataField="address_pick" HeaderText="Address Pick Up" />
<asp:BoundField DataField="drop_off" HeaderText="Drop Off " />
<asp:BoundField DataField="address_drop" HeaderText="Address Drop Off " />
<asp:BoundField DataField="when_going" HeaderText="Date" />
<asp:BoundField DataField="time" HeaderText="Time" />
<asp:BoundField DataField="passenger" HeaderText="Seat" />
<asp:BoundField DataField="seat_price" HeaderText="Price" />
<asp:BoundField DataField="mobile_number" HeaderText="Mobile Number" />
<asp:BoundField DataField="car_name" HeaderText="Car Name" />
<asp:BoundField DataField="car_number" HeaderText="Car Number" />
<asp:ButtonField ButtonType="Button" CommandName="Select" Text="Continue" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</center>
<br />
<asp:Label ID="Label1" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="Label3" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="Label4" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="Label5" runat="server" Text="" Visible="false"></asp:Label>
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["first_name"].ToString();
Label2.Text = Session["email_id"].ToString();
Label3.Text = Session["last_name"].ToString();
Label4.Text = Session["address"].ToString();
Label5.Text = Session["mobile"].ToString();
string id = Request.QueryString["Id"];
if (!string.IsNullOrEmpty(id))
{
string str = ConfigurationManager.ConnectionStrings["carpool_connection"].ConnectionString;
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("select * from offer_register WHERE id = @Id", con);
cmd.Parameters.AddWithValue("@id", id);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
con.Close();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow g1 in GridView1.Rows)
{
string str = ConfigurationManager.ConnectionStrings["carpool_connection"].ConnectionString;
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("insert into bookride(id,first_na,last_na,pick_u,address_pi,drop_off,address_drop,when_going,time,passenger,price,mobile_number,car_na,car_nu,name,pass_email,las_name,address1,mobile) values ('" + g1.Cells[1].Text + "','" + g1.Cells[2].Text + "','" + g1.Cells[3].Text + "','" + g1.Cells[4].Text + "','" + g1.Cells[5].Text + "','" + g1.Cells[6].Text + "','" + g1.Cells[7].Text + "','" + g1.Cells[8].Text + "','" + g1.Cells[9].Text + "','" + g1.Cells[10].Text + "','" + g1.Cells[11].Text + "','" + g1.Cells[12].Text + "','" + g1.Cells[13].Text + "','" + g1.Cells[14].Text + "','" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "','" + Label4.Text + "','" + Label5.Text + "')", con);
con.Open();
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Request Sent.');</script>");
con.Close();
}
}