I am using a detailsview form to update a value. I am using 2 store procedure. One to get the value and another to update the value. My selectCommand to get the value in the detailsview form works fine, but my update store procedure (UpdateCommand) doesn't
work.
The parameters for update store procedure is different than what I have for the Select store procedure. The update store procedure has five parameters, Out of those 4 are selected value from dropdownlist and the last one is the edited value from the detailview
form. I want to know how to reference the control parameter for detailview
in my update paramater list. Below is the code I have used. Can someone look in to and let me know if the way I wrote the update parameter is correct.
also you parameter's name should match your column's name in your select statement. For example, you should have a column name "car_name" in your sp for this parameter Name="car_name"
.
I think I didnt explained it properly. Let me try again. I have a page, where I have 4 databound dropdownlist control and at the bottom I have detailsview form which displays only one value (parm_value). I want to use detailsview form so that I can easily
edit the value without writting much of a code.
The select parameter for detailview has two parameter, i.e. the previous 2 dropdownlist.
But the update command (store procedure) has 5 parameters. i.e the 4 selected value in the dropdownlist and the edited value in the form view.
I need help with writting the update parameters. My Selectcommand works fine.
As far as I know, this doesn't work because it can't parse the DetailsView1$DDL
to figure out what you mean is the ddl control inside the DetailsView.
So you need to do it on the DataSource's Selecting event.
Or you should set the full id, says the clientID, into the ControlID property.
Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support
If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
From what I tested, I will disagree with this statement. But it looks like a hack without writing code to do so..
"As far as I know, this doesn't work because it can't parse the DetailsView1$DDL
to figure out what you mean is the ddl control inside the DetailsView."
I use this syntax to access ddl in both InsertItemTemplate and EditItemTemplate. Interestingly, you may not need this one to access DDL in editItemtemplate.
I can show you in the following code(part of a sample page):
calhydjai
0 Points
9 Posts
Update parameter for detailsview
Jan 23, 2007 02:26 PM|LINK
I am using a detailsview form to update a value. I am using 2 store procedure. One to get the value and another to update the value. My selectCommand to get the value in the detailsview form works fine, but my update store procedure (UpdateCommand) doesn't work.
The parameters for update store procedure is different than what I have for the Select store procedure. The update store procedure has five parameters, Out of those 4 are selected value from dropdownlist and the last one is the edited value from the detailview form. I want to know how to reference the control parameter for detailview in my update paramater list. Below is the code I have used. Can someone look in to and let me know if the way I wrote the update parameter is correct.
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:dataopsConnectionString %>"
<UpdateParameters>SelectCommand="usp_select_parm_value" SelectCommandType="StoredProcedure" UpdateCommand="usp_update_process_parm"
UpdateCommandType="StoredProcedure">
<asp:ControlParameter ControlID="ClientNameDropDownList" Name="car_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ProcessNameDropDownList" Name="file_process_type_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ProcessStepDropDownList" Name="process_step_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ParameterNameDropDownList" Name="parameter_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DetailsView1" Name="parameter_value"
PropertyName="SelectedValue" Type="String" />
/UpdateParameters>
Please help.
Thanks
Control Parameter asp.net 2.0 DetailView detailsView custom update databinding
limno
All-Star
117340 Points
8005 Posts
Moderator
MVP
Re: Update parameter for detailsview
Jan 23, 2007 07:14 PM|LINK
You can try this syntax to access the dropdownlist from your detailsview:
<asp:ControlParameter ControlID="DetailsView1$ClientNameDropDownList" Name="car_name" PropertyName="SelectedValue" Type="String" />
also you parameter's name should match your column's name in your select statement. For example, you should have a column name "car_name" in your sp for this parameter Name="car_name" .
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
calhydjai
0 Points
9 Posts
Re: Update parameter for detailsview
Jan 23, 2007 08:23 PM|LINK
I tried but It didnt worked.
I think I didnt explained it properly. Let me try again. I have a page, where I have 4 databound dropdownlist control and at the bottom I have detailsview form which displays only one value (parm_value). I want to use detailsview form so that I can easily edit the value without writting much of a code.
The select parameter for detailview has two parameter, i.e. the previous 2 dropdownlist.
But the update command (store procedure) has 5 parameters. i.e the 4 selected value in the dropdownlist and the edited value in the form view.
I need help with writting the update parameters. My Selectcommand works fine.
Any help will be greatly appreciated.
Thanks
Rex Lin - MS...
All-Star
17422 Points
2116 Posts
Re: Update parameter for detailsview
Jan 24, 2007 02:59 AM|LINK
Hello calhydjai,
As far as I know, this doesn't work because it can't parse the DetailsView1$DDL
to figure out what you mean is the ddl control inside the DetailsView.
So you need to do it on the DataSource's Selecting event.
Or you should set the full id, says the clientID, into the ControlID property.
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support
If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
limno
All-Star
117340 Points
8005 Posts
Moderator
MVP
Re: Update parameter for detailsview
Jan 24, 2007 03:35 AM|LINK
From what I tested, I will disagree with this statement. But it looks like a hack without writing code to do so..
"As far as I know, this doesn't work because it can't parse the DetailsView1$DDL
to figure out what you mean is the ddl control inside the DetailsView."
I use this syntax to access ddl in both InsertItemTemplate and EditItemTemplate. Interestingly, you may not need this one to access DDL in editItemtemplate.
I can show you in the following code(part of a sample page):
<asp:SqlDataSource ID="SqlDSState" runat="server" SelectCommand="SELECT DISTINCT [state] FROM [authors]" ConnectionString="<%$ ConnectionStrings:MSDN_forumConnectionString %>" />
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDS2" Height="50px" DataKeyNames="au_id"
Width="125px" AutoGenerateRows="False" >
<Fields>
<asp:BoundField DataField="au_id" ReadOnly="True" SortExpression="au_id" InsertVisible="false" />
<asp:BoundField DataField="au_lname" SortExpression="au_lname" />
<asp:TemplateField SortExpression="state">
<EditItemTemplate>
<asp:DropDownList ID="stateDropDown" runat="server" DataSourceID="SqlDSState"
DataTextField="state" DataValueField="state" SelectedValue='<%# Bind("state") %>' />
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="stateDropDown" runat="server" DataSourceID="SqlDSState" DataTextField="state" DataValueField="state" />
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("state") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDS2" runat="server" ConnectionString="<%$ ConnectionStrings:MSDN_forumConnectionString %>"
SelectCommand="SELECT [au_id], [au_lname], [state] FROM [authors] "
UpdateCommand="UPDATE [authors] SET [au_lname] = @au_lname, [state]=@state WHERE [au_id] = @au_id"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id"
InsertCommand="INSERT INTO [authors] ( [au_lname],[state]) VALUES ( @au_lname,@state)">
<UpdateParameters>
<asp:Parameter Name="au_lname" Type="String" />
<%--<asp:ControlParameter Name="state" Type="String" ControlID="DetailsView1$stateDropDown" PropertyName="SelectedValue" />
--%><asp:Parameter Name="au_id" Type="Int32" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="au_id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="au_lname" Type="String" />
<asp:ControlParameter Name="state" Type="String" ControlID="DetailsView1$stateDropDown" PropertyName="SelectedValue" />
</InsertParameters>
</asp:SqlDataSource>
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
calhydjai
0 Points
9 Posts
Re: Update parameter for detailsview
Jan 29, 2007 07:38 PM|LINK
Thanks for your help.
I am able to solve the problem.
Milhoranza
Member
8 Points
5 Posts
Re: Update parameter for detailsview
Mar 29, 2007 05:08 PM|LINK
This solution orked fine to me.
<
asp:ControlParameter ControlID="ctl00$ContentPlaceHolder1$dvBairro$drpEditZona" Name="CD_ZONA" PropertyName="SelectedValue" Type="Int32" />