The meeting room is in three states: idle, applied, and in use

Source: Internet
Author: User

You can view the basic information of a meeting in the DataGrid. If the meeting room is in the "applied" or "in use" status, a link is displayed, click "applied" and "in use" to view the basic information of "applied" and "in use", such as who applied for the application and when it was used up. If the meeting room is idle, no link will appear!

The problem is: In the DataGrid, is the Status column out of the link based on the Status column of the meeting room?
<Script language = "C #" runat = "server">
Void meetingroomstate_itemdatabound (Object sender, datagridcommandeventargs E)
{
If (E. Item. itemtype = listitem. Item) | (E. Item. itemtype = listitem. alternatingitem)
{
Int meetingroomid = int32.parse (E. Item. cells [0]. Text. Trim ());
Int state = getmeetingrootstate (meetingroomid); // get the meeting room status
Label lblstate = (Label) (E. Item. findcontrol ("lblstate "));
Switch (state)
{
Case 1: // applied
Lblstate. Text = "applied" + "<a href = 'showdetails. aspx? Meetingroomid = "+ meetingroomid +"> details </a> ";
Case 2: // in use
Lblstate. Text = "in use" + "<a href = 'showdetails. aspx? Meetingroomid = "+ meetingroomid +"> details </a> ";
Case 3: // idle
Lblstate. Text = "idle" + "<a href = 'requisition. aspx? Meetingroomid = "+ meetingrooid +"> application </a> ";
}
}
}
</SCRIPT>

<Asp: DataGrid id = "meetingroomstate" runat = "server" onitemdatabound = "meetingroomstate_itemdatabound">
<Columns>
<Asp: boundcolumn datafiled = "meetingroomid" headertext = "meeting room ID"/>
<! -- Other columns -->
<Templatecolumns>
<Headertemplate>
Meeting room status
</Headertemplate>
<Itemtemplate>
<Asp: Label id = "lblstate" runat = "server"/>
</Itemtemplate>
</Templatecolumns>
</Columns>
</ASP: DataGrid>

Bytes -------------------------------------------------------------------------------------------------------------

Private void meetinggrid_itemdatabound (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item) | (E. Item. itemtype = listitemtype. alternatingitem ))
{
System. Web. UI. htmlcontrols. htmlinputhidden radioname1;
Radioname1 = (htmlinputhidden) (E. Item. findcontrol ("radioname1 "));
String stateid = radioname1.value. tostring ();

Label lblstate = (Label) (E. Item. findcontrol ("lblstate "));
Int state = int. parse (lblstate. Text. tostring ());

Switch (state)
{
Case 0:
Lblstate. Text = "idle ";
Break;
Case 1:
Lblstate. Text = "<a href = 'applydetails. aspx? Meetingid = "+ stateid +" '> applied </a> ";
Break;
Case 2:
Lblstate. Text = "<a href = 'applydetails. aspx? Meetingid = "+ stateid +" '> in use </a> ";
Break;
}

}
}

 

<Asp: DataGrid id = "meetinggrid" runat = "server" width = "100%" autogeneratecolumns = "false">
<Headerstyle font-names = "" horizontalalign = "center" backcolor = "# cbd8ef"> <Columns>
<Asp: templatecolumn headerimageurl = "modify" headertext = "operation">
<Itemstyle horizontalalign = "center"> </itemstyle>
<Headertemplate>
Select
</Headertemplate>
<Itemtemplate>
<Input id = radioname1 type = hidden value = '<% # databinder. eval (container. dataitem, "ID") %> 'runat = "server">
<Input id = radioname type = radio value = '<% # databinder. eval (container. dataitem, "ID") %> 'name = radioname>
</Itemtemplate>
</ASP: templatecolumn>
<Asp: boundcolumn datafield = "roomno" headertext = "meeting room no.">
<Itemstyle horizontalalign = "center"> </itemstyle>
</ASP: boundcolumn>
<Asp: templatecolumn headertext = "meeting room name">
<Headerstyle wrap = "false" backcolor = "# cbd8ef"> <Itemstyle wrap = "false"> </itemstyle>
<Itemtemplate>
<A href = 'meetingdetails. aspx? Id = <% # databinder. eval (container. dataitem, "ID") %> 'target = "_ Self">
<% # Databinder. eval (container. dataitem, "roomname") %>
</A>
</Itemtemplate>
</ASP: templatecolumn>
<Asp: boundcolumn datafield = "containpernum" headertext = "inpernum">
<Itemstyle horizontalalign = "center"> </itemstyle>
</ASP: boundcolumn>
<Asp: boundcolumn datafield = "Address" headertext = "meeting room address">
<Itemstyle horizontalalign = "center"> </itemstyle>
</ASP: boundcolumn>
<Asp: templatecolumn headertext = "current state">
<Headerstyle wrap = "false" backcolor = "# cbd8ef"> <Itemstyle wrap = "false" horizontalalign = "center"> </itemstyle>
<Itemtemplate>
<Asp: Label id = "lblstate" runat = "server" text = '<% # databinder. eval (container. dataitem, "currentstate") %>'/>
</Itemtemplate>
</ASP: templatecolumn>
<Asp: boundcolumn datafield = "creater" headertext = "Registrant">
<Itemstyle horizontalalign = "center"> </itemstyle>
</ASP: boundcolumn>
<Asp: boundcolumn datafield = "createdate" headertext = "Registration Date" dataformatstring = "{0: d}">
<Itemstyle horizontalalign = "center"> </itemstyle>
</ASP: boundcolumn>
</Columns>
</ASP: DataGrid>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.