Please refer to the following GUI and Codebehind:
[HTML]<body>
<form id="form1" runat="server">
<cc1:ToolkitScr iptManager ID="ToolkitScri ptManager1" runat="server">
</cc1:ToolkitScri ptManager>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:DataGrid ID="dgBroken" runat="server" CellPadding="4" ForeColor="#333 333" GridLines="None " AutoGenerateCol umns="false" OnDataBound="Gr idView1_DataBou nd">
<FooterStyle BackColor="#5D7 B9D" Font-Bold="True" ForeColor="Whit e" />
<EditItemStyl e BackColor="#999 999" />
<SelectedItemSt yle BackColor="#E2D ED6" Font-Bold="True" ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e" HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True" ForeColor="Whit e" />
<AlternatingIte mStyle BackColor="#EEE EEE" ForeColor="#000 000" />
<ItemStyle BackColor="Whit e" ForeColor="#000 000" />
<Columns>
<asp:BoundColum n DataField="JobB EffDte" HeaderText="Dat e Posted" DataFormatStrin g="{0:d}" />
<asp:TemplateCo lumn HeaderText="Job Title">
<ItemStyle Width="150px" />
<ItemTemplate >
<asp:LinkButt on ID="lnkExpand" runat="server" Text="+" ForeColor="#465 D7E" OnClick="lnkExp and_click">
<asp:Label ID="lblTtlDesc " runat="server" Text='<%# DataBinder.Eval (Container,"Dat aItem.TtlDesc") %>'></asp:Label>
</asp:LinkButton>
<asp:Label ID="lblTtlInfo " runat="server" Visible="false" Text='<%# DataBinder.Eval (Container,"Dat aItem.TtlInfo") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="DepD esc" HeaderText="Dep artment" />
<asp:TemplateCo lumn HeaderText="Loc ation">
<ItemStyle Width="150px" />
<ItemTemplate >
<asp:Label ID="lblLocDesc " runat="server" Text='<%# DataBinder.Eval (Container,"Dat aItem.BraCity") + ", " + DataBinder.Eval (Container,"Dat aItem.BraName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</ContentTemplate >
</asp:UpdatePanel >
</form>
</body>[/HTML]
CODE BEHIND:
Expand|Select|Wrap|Line Numbers
- public partial class postAPosition : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- BindDataGrid();
- AddEventHandlers();
- }
- private void AddEventHandlers()
- {
- dgBroken.ItemDataBound += new DataGridItemEventHandler(dgBroken_ItemDataBound);
- }
- protected void dgBroken_ItemDataBound(object sender, DataGridItemEventArgs e)
- {
- try
- {
- if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.SelectedItem)
- {
- Label lblTtlInfo = (Label)e.Item.FindControl("lblTtlInfo");
- LinkButton lnkExpand = ((LinkButton)(e.Item.FindControl("lnkExpand")));
- if (lnkExpand.Text == "+")
- {
- lblTtlInfo.Visible = false;
- }
- else
- {
- lblTtlInfo.Visible = true;
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- protected void lnkExpand_click(object sender, EventArgs e)
- {
- LinkButton lb = (LinkButton)sender;
- if (lb.Text == "+")
- {
- lb.Text = "-";
- AddEventHandlers();
- BindDataGrid();
- }
- else if (lb.Text == "-")
- {
- lb.Text = "+";
- AddEventHandlers();
- BindDataGrid();
- }
- }
- private void BindDataGrid()
- {
- DataSet dsTrial = BllJobListingsA.Select(1);
- dgBroken.DataSource = dsTrial;
- dgBroken.DataBind();
- }
- }
- }