Help needed to pass client side values in asp.net website
How can i pass value from grid view to a pop up in client side. I have a edit button in the grid view and when user clicks that the value(EditExpiresBy) from selected row should be in a text box in the pop up.
<asp:Panel ID="EditPanel" runat="server">
开发者_JAVA技巧 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txt_EditExpiresBy" runat="server" ></asp:TextBox>
<asp:Button ID="btn_EditSave" runat="server" Text="Save" onclick="btn_EditSave_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
and a PopupControlExtender.
How can I pass the value in client side. help needed
One way to do this is to have a DetailsView
that is linked to the SelectedValue
property of your GridView
. You can put the DetailsView
in the popup, and it will display whatever was selected in the GridView
Sample DetailsView
Note: you would be putting this in place of the txt_EditExpiresBy TextBox control
<asp:DetailsView ID="detailsView" runat="server" AutoGenerateRows="False"
DataKeyNames="yourIDField" DataSourceID="detailsSqlDataSource"
Height="50px" Width="287px" >
<Fields>
<asp:BoundField DataField="ExpiresBy" HeaderText="Expires By"
SortExpression="ExpiresBy" />
<%--Whatever other fields you want to include--%>
</Fields>
</asp:DetailsView>
Sample Data source (for the DetailsView
)
<asp:SqlDataSource ID="detailsSqlDataSource" runat="server"
ConnectionString="Your Connection String" SelectCommand="SELECT [ExpiresBy] FROM [tableName] WHERE yourTableID = @yourTableID">
<SelectParameters>
<asp:ControlParameter ControlID="yourGridView" Name="yourTableID"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
See the ControlParameter
in this DataSource looks at the ID of the row that was selected in the GridView
and uses that to populate the DetailsView
.
Let me know if any of this is not clear and I'll try to explain myself better, this is just the way I usually do it.
精彩评论