Sahil Jani

Sahil Jani

  • NA
  • 274
  • 154.6k

GridView Control

Jul 15 2011 8:31 AM
Hi,

This is my .aspx page ::

 <asp:Button ID="btnCreate" runat="server" Text="Create New Doc" 
        onclick="btnCreate_Click" />
    <asp:GridView ID="gvRequests" runat="server" CellPadding="4" Width="100%" AutoGenerateColumns="False"
        AutoPostBack="true" DataKeyNames="RequestId,RequestCompanyName,StepID"
        CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="chkSelected" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="RequestCompanyName" HeaderText="Company Name" />
            <asp:TemplateField HeaderText="Status">
                <ItemTemplate>
                    <asp:Label ID="lblStatus" runat="server" Text='<%# GetStatus(Convert.ToInt32( Eval("StepId"))) %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="CreatedDateTime" HeaderText="Last Modified Date" />
        </Columns>
    </asp:GridView>

This is my .aspx.cs page ::

 public partial class Home : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            gvRequests.DataSource = BusinessUtility.SelectCurrentRequestsForUser(Master.PageController.UserData.CompanyId);
            gvRequests.DataBind();
        }

        public string GetStatus(int stepId)
        {
            if (stepId == 3)
                return "Saved - Mapping to be verified";
            if (stepId == 4)
                return "Mapping Verified";
            if (stepId == 5)
                return "Directors Info Entered";
            if (stepId == 10)
                return "Completed";
            else
                return "Unknown";
        }
}

I just need to check that if my bound field' status id is incomplete then user can not able to press Create New Button, otherwise User can.


Pls help as soon as pos.

Thanks in advance.

Answers (1)