I have a ObjectDataSource which is placed in de source code of my .aspx page, not the code behind, and is used inside an EditTemplate column of a datagrid.
<asp:DropDownList ID="ddlist1" runat="server" DataSourceID="osCreditType" ...
After selecting a value in the dropdown and setting the datagrid state back to ItemTemplate, I have the ValueMember of that DropDownItem in the NewValues collection inside the RowUpdating Event.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int primary = int.Parse(Convert.ToString(e.NewValues[0]));
}
Now, I wa开发者_开发百科nt to retrieve some other information from the ObjectDataSource using that primary.
- Is the data, used for the dropdown still available in the ObjectDataSource, or will a call to that source from code-behind make the datasource go back to the database
- Can I use the ObjectDataSource to retrieve additional information using this primary key, and if so, how do I accomplish it ?
Thanks a lot in advance
You have to remember that the ObjectDataSource is really just a Binder between your Data Layer and Your Controls.
What would be better is for you in the GridView1_RowUpdating routine is to use a SqlDataAdapter and go and get the information from the database yourself and then use that information to change the values of the Updated Row.
You will have a problem trying to run another Query with the Same ObjectDataSource, cause as soon as you do that the control will try to rebind to the new data.
Hope this helps.
精彩评论