Dear Sarah Oliver,
We have framed solution for your requirements. But there are pre-requirements:
(1) (1) Use AjaxControlToolkit 4.0 instead of AjaxControlToolkit 2.0. Because onclick event of button (in Accordion control’s template) will not be executed for 2.0 as it is a bug.
(2) (2) The table in database should have primary key. We have used AdmNo of type int as primary key.
Here is the code snippet (in .aspx page):
<ajax:Accordion ID="accMenu" HeaderCssClass="header" SelectedIndex="0" ContentCssClass="content"
HeaderSelectedCssClass="selected" AutoSize="Limit" EnableViewState="true" runat="server"
CssClass="rmenu" Height="340px" Width="30%">
<%# Eval("Student") %>
Admission No. :
<%# Eval("AdmNo") %><br />
OBC: <%# Eval("Obc") %><br />
<asp:Label ID="lblEmail" runat="server" /><br />
<asp:Button ID="btnGiveEmail" runat="server" Text="Get Email" OnClientClick="SetHeaderTemplateIndex()"
As you can notice we have bind accordion control accMenu’s template items to database values. Further there is button declared which will execute function to retrieve Email field values and set email value to Label later. We have not used Update query as per your requirement. But the code snippet will help you to understand functioning.
To get information about click button from specific content pane, we would retrieve selected index value of Accordion. The very first index would return value as 0 (zero). SelectedIndex will let us to know which button clicked. And we will search that pane’s controls to modify.
Code snippet in (.aspx.cs page):
protected void btnGiveEmail_Click(object sender, EventArgs e)
int admNo = accMenu.SelectedIndex + 1;
string query = "SELECT Email FROM Students WHERE AdmNo=" + admNo;
DataTable dt = GetData(query);
AccordionPane pane = accMenu.Panes[accMenu.SelectedIndex];
Label lbl = pane.FindControl("lblEmail") as Label;
lbl.Text = "Email: " + dt.Rows["Email"].ToString();
Instead of SELECT query you can use UPDATE query. And then later modify those values. If you need more help let us know.