Hello,When I click on the gridview edit button and select a value from the ComponentID DropDown list I would like fields, tbxFunctions, tbxFuncFail, and tbxFailMode to be updated with the information that matched the ComponentID from tblFailures:
Question 1) do I need to create an object data source or sql data source to get functions, funcFail, and failMode by ComponentID
Question 2) Not Sure how to set the text property to for tbxFunctions, tbxFuncFail, and tbxFailMode. Do I add a Select Parameter statement below?<
SelectParameters> <asp:ControlParameter ControlID="ddlControlID" Name="ControlID" PropertyName="SelectedValue" Type="String" />******************************************************************************************
tblComponent
ComponentID int 4
SubSystemID int 4
Component nvarchr 60
ComponentDesc nvarchr 150
Inactive bit 1tblFailures:
FailureID int 4
ComponentID int 4
Functions nvarchar 255 (tbxFunctions)
FuncFail nvarchar 255 (tbxFuncFail)
FailMode nvarchar 255 (tbxFailMode)
*********************************************************************************************
ASPX
DropDownList Component: ddlComponent
<asp:TemplateField HeaderText="ComponentID" SortExpression="ComponentID">
<ItemTemplate> <asp:Label ID="lblComponent" runat="server" Text='<%# Eval("ComponentID") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlComponent" runat="server" OnDataBound="ddlComponent_DataBound" DataSourceID="cpddlODS" DataTextField="Component" DataValueField="ComponentID"> </asp:DropDownList><asp:ObjectDataSource ID="cpddlODS" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GettblComponentBySubSystemID" TypeName="tblComponentBLL"> <SelectParameters> <asp:ControlParameter ControlID="ddlSubSystem" Name="SubSystemID" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> <asp:RequiredFieldValidator ForeColor="white" ID="valddlComponent" runat="server" ErrorMessage="Cannot leave the ComponentID selection blank" Text="*" Display="Dynamic" ControlToValidate="ddlComponent"></asp:RequiredFieldValidator> </EditItemTemplate> <FooterTemplate> <asp:DropDownList ID="NewComponent" runat="server"> </asp:DropDownList> </FooterTemplate> </asp:TemplateField>******************************************************************************************************
Text Fields To Be Updated
<asp:TemplateField HeaderText="Functions" SortExpression="Functions">
<EditItemTemplate>
<asp:TextBox ID="tbxFunctions" runat="server" Text='<%# Bind("Functions") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblFunctions" runat="server" Text='<%# Bind("Functions") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="NewFunctions" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FuncFail" SortExpression="FuncFail">
<EditItemTemplate>
<asp:TextBox ID="tbxFuncFail" runat="server" Text='<%# Bind("FuncFail") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblfuncFail" runat="server" Text='<%# Bind("FuncFail") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="NewFuncFail" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FailMode" SortExpression="FailMode">
<EditItemTemplate>
<asp:TextBox ID="tbxFailMode" runat="server" Text='<%# Bind("FailMode") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblFailMode" runat="server" Text='<%# Bind("FailMode") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="NewFailMode" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>********************************************************************************************
Question 3)
Code Behind - Trying but need some direction and do I need to tie in a query to get and display the records that match the ComponetID value ?
Protected Sub ddlComponent_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) If ddlComponentID.SelectIndex <>-1 ThentbxFunctions.text = ddlComponentID.SelectedItem.Text
tbxFuncFail= ddlComponentID.SelectedItem.Text
tbxFailMode= ddlComponentID.SelectedItem.Text
End If
End Sub
Thank you,
ptown
![]() |
0 |
![]() |
Hey Ptown,
sorry to ask you like this, please clarify to me regarding what you are trying to acheive . this is what i understood from your post,
you have DDL in a gridview, you want to select something from that DDL say for example EmpID( employee id) and based on that value , you want to generate 3 textboxes say like EmpName, Age, Salary. are the textboxes inside the grid or outside.
please correct me if i am wrong.
Thanks a lot
Keyboard not found. Please Press < F1 > to RESUME
Please Remember to Mark as Answer for the post(s) that help you.....so it can help others......Thanks
![]() |
0 |
![]() |
-
ptown
![]() |
0 |
![]() |
Hello and thank you,
I have a ddl in gridview called ddlComponetID. When you select a value from ddlComponentID say for example ComponentID 1 (3.6v Battery Pack) then TextBoxes Make, Model, and SerialNumber will be filled in instead of typing in the information. I found an articl that is similiar, but it is for a details View, http://forums.asp.net/t/1080990.aspx. I want to do the same thing but for gridview. I am having difficulity changing the systax for gridview. This is what I have and the system does not like it, I'm trying.
Protected Sub ddlComponent_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim cpddl As DropDownList = CType(sender, DropDownList)Dim myDetailsView As DetailsView = CType(cpddl.NamingContainer, DetailsView) ' Dim gvRow As GridViewRow = DirectCast(cpddl.NamingContainer, GridViewRow) If myDetailsView.CurrentMode = DetailsViewMode.Edit Then ' If e.Row.RowType = DataControlRowType.DataRow AndAlso e.Row.RowState = DataControlRowState.Edit Then
GetFailureInfoDS.SelectParameters.Clear()
GetFailureInfoDS.SelectParameters.Add("ComponentID", cpddl.SelectedValue) Dim gv As System.Data.DataView = CType(GetFailureInfoDS.Select(DataSourceSelectArguments.Empty), System.Data.DataView)Dim tbxF As TextBox = GridView1.FindControl("tbxFunctions") Dim tbxFF As TextBox = GridView1.FindControl("tbxFuncFail")Dim tbxFM As TextBox = GridView1.FindControl("tbxFailMode")tbxF.Text = gv(0)(
"Functions").ToStringtbxFF.Text = gv(0)("FunctionalFailures").ToString tbxFM.Text = gv(0)("FailureModes").ToString End If End Sub
ptown
![]() |
0 |
![]() |
i'm sorry the text boxes are in the grid
ptown
![]() |
0 |
![]() |
issue resolved
ptown
![]() |
0 |
![]() |