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>