/ Published in: C#
Expand |
Embed | Plain Text
<asp:GridView id="gvGridView" runat="server" AutoGenerateColumns="False" > <Columns> </Columns> </asp:GridView> gvGridView.DataSource = dtDataTable; gvGridView.DataBind(); <asp:TemplateField> <ItemTemplate> <a href='default.aspx?cid=<%# Eval("id") %>&sid=<%=Request.QueryString["id"].ToString()%>'><%# Eval("Column") %></a> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="" HeaderText="" HtmlEncode="false" DataFormatString="{0:MM/dd/yyyy}" SortExpression="" /> <asp:HyperLinkField DataNavigateUrlFields="ID" DataTextFormatString="{0}" DataNavigateUrlFormatString="default.aspx?id={0}" DataTextField="" HeaderText="" /> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <asp:HyperLink ID="hlName" runat="server" NavigateUrl='<%# ("page.aspx?id=" + Eval("ID")) %>' /> </ItemTemplate> </asp:TemplateField> <asp:LinkButton ID="lbButton" CommandArgument='<%# Eval("ID") %>' OnCommand="gvCommand_Command" Text="" runat="server" /> CONFIRM DELETE: OnRowDataBound="GridView_RowDataBound" <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="lbDelete" CommandArgument='<%# Eval("id") %>' OnCommand="lbDelete_Command" Text="Delete" runat="server" /> </ItemTemplate> </asp:TemplateField> protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //e.Row.Attributes.Add("onmouseover", "Highlight(this);"); //e.Row.Attributes.Add("onmouseout", "resetColorRows();"); LinkButton lbDelete = (LinkButton)e.Row.FindControl("lbDelete"); if (lbDelete != null) { DataRowView drv = (DataRowView)e.Row.DataItem; if (drv["Name"] != null) lbDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete \\'" + drv["Name"].ToString().ToUpper() + "\\'');"); } } }
You need to login to post a comment.
