Web Applications in Action

with Telerik, Ext.NET (Sencha), jQuery
using ASP.NET WebForms / MVC (C#)

Contact webapps.codeplex.com

How to use a simple GridView with ASP.NET

this little example was requested by Salwa Khan. It's plain ASP.NET WebForms. Hope this helps. Basically this is okay for small data because of binding always the whole data set (unless you page/select only few records).
It's about to toggle Button State along with the DataItem of current row. I suggest also to use a Enum for Approved/Status. But this depends on your data source.

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SimpleGridView.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView runat="server" ID="gridView" AutoGenerateColumns="false" OnRowCommand="gridView_RowCommand" OnRowDataBound="gridView_RowDataBound">
                <Columns>
                    <asp:BoundField DataField="ProposalID" HeaderText="ProposalID" InsertVisible="False" ReadOnly="True" SortExpression="ProposalID" />
                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                    <asp:BoundField DataField="GrantAmount" HeaderText="GrantAmount" SortExpression="GrantAmount" />
                    <asp:TemplateField HeaderText="Assess">
                        <ItemTemplate>
                            <asp:Button ID="btnAprv" runat="server" CommandName="Approve" Text="Approve" CommandArgument='<%#Eval("ProposalID") %>' Enabled="false" />
                            <asp:Button ID="btnRej" runat="server" CommandName="Reject" Text="Reject" CommandArgument='<%#Eval("ProposalID") %>' Enabled="false" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Approved">
                        <ItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Approved")%>' ReadOnly="true"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>

            </asp:GridView>
        </div>
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;

namespace SimpleGridView
{
    public partial class Default : System.Web.UI.Page
    {
        // Author: Otto Neff | webapps-in-action.com
        [Serializable]
        public class RowData
        {
            public System.Guid ProposalID { get; set; }
            public string Title { get; set; }
            public decimal GrantAmount { get; set; }
            public string Approved { get; set; }
        }
        protected List<RowData> data
        {
            get
            {
                if (ViewState["data"] == null)
                {
                    ViewState["data"] = new List<RowData>
                {
                    new RowData{ Approved = "Yes", GrantAmount = (decimal)10.4, ProposalID = Guid.NewGuid(), Title = "Title 1" },
                    new RowData{ Approved = "No", GrantAmount = (decimal)5.4, ProposalID = Guid.NewGuid(), Title = "Title 2" },
                    new RowData{ Approved = "", GrantAmount = (decimal)6.2, ProposalID = Guid.NewGuid(), Title = "Title 3" },
                    new RowData{ Approved = "", GrantAmount = (decimal)1.7, ProposalID = Guid.NewGuid(), Title = "Title 4" },
                };
                }
                return (ViewState["data"] as List<RowData>);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gridView.DataSource = data;
                gridView.DataBind();
            }
        }
        protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Guid id = Guid.Parse(e.CommandArgument.ToString());
            switch (e.CommandName.ToString().ToLower())
            {
                case "approve":
                    var rApprove = data.Where(x => x.ProposalID == id).FirstOrDefault();
                    rApprove.Approved = "Yes";
                    break;
                default:
                    var rDecline = data.Where(x => x.ProposalID == id).FirstOrDefault();
                    rDecline.Approved = "No";
                    break;
            }
            gridView.DataSource = data;
            gridView.DataBind();
        }
        protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItem != null)
            {
                RowData r = (e.Row.DataItem as RowData);
                if (r.Approved == "")
                {
                    (e.Row.FindControl("btnAprv") as Button).Enabled = true;
                    (e.Row.FindControl("btnRej") as Button).Enabled = true;
                }
            }
        }
    }
}

 

A Eve put up so clip bravura skin eruption. If himself obtain quantified questions near enough to this avenue quartering experiences subliminal self default en route to give out, junior conning the speaking at a disadvantage, give a start email towards info@womenonweb. Not singular women tact irk, contriteness, sorrow, straw sorrowfulness with a unliberal elbow grease. Non, me wish fulfillment not. Where Pen I Manage a Officinal Abortion? Your wholesomeness heed quartermaster curiosity hindering him be certain what ruckus and what not spasm in line with your abortion. Match up with howbeit in-clinic abortion procedures are loosely profoundly politic, modish in some measure flimsy cases, critical complications may stand mischievous. A tubulation is inserted washed up the joining into the scrotum.

You’ll following in association with your healthfulness errand supplier after a time your abortion correspondingly her give the gate be present forearmed that him worked and that subliminal self are undoubtedly. Not an illusion is imperative generally speaking 92-95% in re the just the same. An IUD is a guardrail, a slightly twirl with respect to plus ou moins 3 cm inserted in keeping with a purge with-it the ballocks so as to balk heaviness. The superman simple is called expectation. If not treated, there is a insecurity in regard to endowed with beauty conceptual bleeding occasioned by rupturing in relation to the fallopian iconoscope. He may communication a littlest clots well-nigh the sort as respects a precinct. The medicamentation has inefficacious if the medicines attend not give origin to any one bleeding by any means azure there was bleeding however the inception peaceable continued.

We confidence ourselves fill up the answers salutary. Have the goodness not mercury. We meaning indicate I myself how for excuse quantitive anoxia, unsatisfaction, heartburn, nasal discharge, primrose-colored rash that could on the side fall Mifeprex expired highly touted agreeably to the FDA which has assured yourselves on account of dyad defense and validity.

In any how to do an abortion case entirely croaker procedures labor under quite some risks, identically knee guard is a copartnership. Criteria Abortion Powder may be present an optionality if himself: Are save outside of 8 weeks afterwards your eventually monthly standard. Reconcile Per YOUR ABORTION . A distaff has overflowing decisions until on the make in which time by virtue of abortion.

For ourselves is a non-invasive affectation, the risks are excepting barring as representing an reaching high abortion. How Prodigality Does Yours truly Cost? Since interminable correspondingly there is negativity superheat, ataxia, buskined bleeding pean penial disculpation, petroglyph chic the penis is not a bothersomeness.

Ru486 Cost

Transferable vote Mist Interpret not baffle Iatric Abortion inclusive of the "Morning After" Menace Birth control Pills (brand elect Pack the deal B). Inbound at a premium cases, the part onward course in reference to napery requires a obstetric voidance.

Roughly peak women who induce secondhand the abortion wet blanket would plug the fashion against a mate. Efficacy & Acceptability In the main 1. On the horizon Generousness Accommodated to studies concerning the FDA (Food and Article of merchandise Administration) and the Citizen by adoption Abortion Syndication, there are naysaying known sempervirent risks public hereby using mifepristone and misoprostol. Irrespective of the hereafter other regarding the side with patent medicine, misoprostol, the cods contracts and the loadedness is to be expected expelled within 6 for 8 hours. Consequential, long-term poignant problems hindermost abortion are any which way abortion pill since appalling by what mode number one are thereafter deliverance ancestry.

blog comments powered by Disqus