ObjectDataSource.Selected Event
ObjectDataSource.Selected Event
Occurs when a Select operation has completed.
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
<form id="Form1" method="post" runat="server">
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
<asp:objectdatasource
4
ID="ObjectDataSource1"
5
runat="server"
6
SelectMethod="GetFullNamesAndIDs"
7
TypeName="Samples.AspNet.CS.EmployeeLogic" />
8![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
<p>
10
<asp:dropdownlist
11
ID="DropDownList1"
12
runat="server"
13
DataSourceID="ObjectDataSource1"
14
DataTextField="FullName"
15
DataValueField="EmployeeID"
16
AutoPostBack="True"
17
AppendDataBoundItems="true">
18
<asp:ListItem Text="Select One" Value=""></asp:ListItem>
19
</asp:dropdownlist>
20
</p>
21![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
<asp:objectdatasource
23
ID="ObjectDataSource2"
24
runat="server"
25
SelectMethod="GetEmployee"
26
UpdateMethod="UpdateEmployeeAddress"
27
OnUpdating="EmployeeUpdating"
28
OnSelected="EmployeeSelected"
29
TypeName="Samples.AspNet.CS.EmployeeLogic" >
30
<SelectParameters>
31
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="-1" Name="empID" />
32
</SelectParameters>
33
</asp:objectdatasource>
34![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
<asp:DetailsView
36
ID="DetailsView1"
37
runat="server"
38
DataSourceID="ObjectDataSource2"
39
AutoGenerateRows="false"
40
AutoGenerateEditButton="true">
41
<Fields>
42
<asp:BoundField HeaderText="Address" DataField="Address" />
43
<asp:BoundField HeaderText="City" DataField="City" />
44
<asp:BoundField HeaderText="Postal Code" DataField="PostalCode" />
45
</Fields>
46
</asp:DetailsView>
47![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
48
</form>
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
public void EmployeeUpdating(object source, ObjectDataSourceMethodEventArgs e)
2![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
3
DataContractSerializer dcs = new DataContractSerializer(typeof(Employee));
4![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
String xmlData = ViewState["OriginalEmployee"].ToString();
6
XmlReader reader = XmlReader.Create(new StringReader(xmlData));
7
Employee originalEmployee = (Employee)dcs.ReadObject(reader);
8
reader.Close();
9![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
e.InputParameters.Add("originalEmployee", originalEmployee);
11
}
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
public void EmployeeSelected(object source, ObjectDataSourceStatusEventArgs e)
14![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
15
if (e.ReturnValue != null)
16![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
17
DataContractSerializer dcs = new DataContractSerializer(typeof(Employee));
18
StringBuilder sb = new StringBuilder();
19
XmlWriter writer = XmlWriter.Create(sb);
20
dcs.WriteObject(writer, e.ReturnValue);
21
writer.Close();
22![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
ViewState["OriginalEmployee"] = sb.ToString();
24
}
25
}
Occurs when a Select operation has completed.
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
44
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
46
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
48
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)