hello everyone.
can any one tell me how to delete recored from gired view dynamically.
in my program i have one gridview and sqlDatasource in this i have 4 label and one button.Label shows name, date, title and description and button for delete.
all this is done at source view through adding 2 template field and this template field contain label and button. it show recordes as i want.
but the problem is now i want to delete perticuler name and description from the gridview so i had created button in templte field.how to do it can any one sugest me what to do.
thoiis is my query.
Select t1.Id,t1.Name,t1.Date,t1.Description,t2.Body,t2.optionId,t2.AdDate,t2.AdedBy from tabel1 t1 full outer join table2 t2 ON t1.Id=T2.Id
this is my code of gridview
<asp:GridView ID="GridView1" runat="server" Height="139px" Width="562px" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True" HorizontalAlign="Justify" BackColor="LightGoldenrodYellow" BorderColor="Black" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" BorderStyle="Solid">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Literal ID="Literal6" runat="server" Text='<%# Eval("UserDt", "{0:D}<br/><br/>{0:T}") %>'></asp:Literal><br />
<hr style="width: 100px; height: 1px" />
<asp:Literal ID="Literal7" runat="server" Text='<%# Eval("UserAd", "{0}") %>'></asp:Literal><br />
<br />
<asp:Button ID="Button2" runat="server" Text="Delete" OnClientClick="if (Confirm('Are you sure you want to delet this{0}?'==false) return false;" />
</ItemTemplate>
<ItemTemplate>
<div class="title">
<asp:Literal ID="Literal3" runat="server" Text='<%# Eval("Title", "{0}") %>'></asp:Literal>
<br />
<br />
<asp:Literal ID="Literal5" runat="server" Text='<%# Eval("Body", "{0}") %>'></asp:Literal><br/>
</div>
</ItemTemplate>
<FooterStyle BackColor="Tan" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
here i'm trying to write some code for delete but i don't know what to write.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim id As Integer
id = GridView1.Rows.Count
If id = 1 Then
Exit Sub
End If
Dim btn As Button = e.Row.FindControl("button1")
btn.OnClientClick=String.Format(btn.OnClientClick,
End If
End Sub
sorry for my poor english and for this tuck of code but sgest me what to do.