I am new to asp.net.I have gridview which displays data from database.One of the field contains image.The image which is shown dynamically as only image path is stored in database.
My table contains fields
Car_Name
Car_Id
Car_Photo
No_of_Seats
Now what i want is when user clicks on image i want a pop up image in modal.....or image should be zoomed something like that....
<%# Page Title="" Language="C#" MasterPageFile="~/Project/MasterPage/MasterPage.master"
AutoEventWireup="true" CodeFile="Reserve.aspx.cs" Inherits="Project_Reserve_Reserve" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="reserve.css" rel="stylesheet" type="text/css" />
<script src="../../javascript/jquery-1.9.0.js" type="text/javascript"></script>
<%-- <script src="myscript.js" type="text/javascript"></script>
<script src="f12.js" type="text/javascript"></script>--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="homepageContentPlaceHolder" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Select Start Date
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" Enabled="True"
TargetControlID="TextBox1">
</asp:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="*"></asp:RequiredFieldValidator>
<br />
<br />
Select End Date
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="TextBox2_CalendarExtender" runat="server" Enabled="True"
TargetControlID="TextBox2">
</asp:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:AnimationExtender ID="RequiredFieldValidator2_AnimationExtender" runat="server"
Enabled="True" TargetControlID="RequiredFieldValidator2">
</asp:AnimationExtender>
<br />
<br />
<br />
Select Model <asp:DropDownList ID="ddlModel" runat="server"
AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="Model_Name" DataValueField="Model_Id" OnSelectedIndexChanged="ddlModel_SelectedIndexChanged"
Width="100px">
<asp:ListItem Value="0">--Select--</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlModel"
ErrorMessage="Select a Model"></asp:RequiredFieldValidator>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Model]"></asp:SqlDataSource>
<br />
<br />
<br />
<asp:GridView ID="gvcar" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None" EmptyDataText="No data found!">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Car_Name" HeaderText="Car Name" />
<asp:BoundField DataField="No_of_Seats" HeaderText="Seats" />
<asp:TemplateField HeaderText="Photo">
<ItemTemplate>
<asp:Image Width="300" Height="200" ID="Image1" runat="server" ImageUrl='<%# Eval("Car_Photo") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div>
<h3>
<em>Sorry...No Car is available rightnow for this model</em></h3>
</div>
</EmptyDataTemplate>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:Button runat="server" ID="btnModalPopUp" Style="display: none" />
<br />
<br />
<br />
<asp:Button ID="btnbook" runat="server" Text="Book" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Following links might be helpful to you:
http://technico.qnownow.com/zoom-image-on-mouse-over-in-asp-net-gridview-control/
and
http://www.aspdotnet-suresh.com/2011/12/jquery-fancy-zoom-effect-for-image-in.html
hope its helpful.
Related
I have a grid view with some command field (delete, edit),they work until I put the grid view in an update panel.
it is a asp.net web form.
thank a lot... I'm not use to work with asp.net
<h2><%: Title %>Contact List</h2>
<h3>click any contact to edit...</h3>
<asp:Button ID="insert1" runat="server" Height="21px" OnClick="insert1_Click" Text="new contact" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:contact_atidConnectionString %>"
SelectCommand="SELECT * FROM [contact_list]"
DeleteCommand="delete from [contact_list] where id=#id"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" Height="30px"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="453px"
OnRowDeleted="GridView1_RowDeleted" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" EnablePersistedSelection="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" ReadOnly="True" />
<asp:BoundField DataField="first name" HeaderText="first name" SortExpression="first name" />
<asp:BoundField DataField="last name" HeaderText="last name" SortExpression="last name" />
<asp:CommandField ShowDeleteButton="True" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
I found my problem! I simply forget to put the list view that the commad button have to open in the update panel.
here is the correct code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" Height="30px"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="453px"
OnRowDeleted="GridView1_RowDeleted" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" EnablePersistedSelection="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
CssClass="table table-striped">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" ReadOnly="True" />
<asp:BoundField DataField="first name" HeaderText="first name" SortExpression="first name" />
<asp:BoundField DataField="last name" HeaderText="last name" SortExpression="last name" />
<asp:CommandField ShowDeleteButton="True" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:contact_atidConnectionString %>"
SelectCommand="SELECT * FROM [contact_list]"
DeleteCommand="delete from [contact_list] where id=#id"></asp:SqlDataSource>
<asp:Panel runat="server">
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource2" Visible="true">
<ItemTemplate>
<tr runat="server">
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="SAVE" CommandName="save" OnClick="EditButton_Click" CssClass="btn btn-default btn-lg" BackColor="MediumSpringGreen" />
</td>
<td>
<asp:TextBox ID="TextBox101" runat="Server" Text='<%#Eval("id") %>' Visible="false" class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="FirstNameLabel" runat="Server" Text='<%#Eval("first name") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="LastNameLabel" runat="Server" Text='<%#Eval("last name") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox1" runat="Server" Text='<%#Eval("[street]") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox5" runat="Server" Text='<%#Eval("born date") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox2" runat="Server" Text='<%#Eval("house number") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox3" runat="Server" Text='<%#Eval("telephone") %>' class="form-control input-sm" />
</td>
<td>
<asp:TextBox ID="TextBox4" runat="Server" Text='<%#Eval("pelephone") %>' class="form-control input-sm" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
thank you :)
I have a GridView in which the last Column has a Button which loads data.
Doing that takes like 2 Minutes.So, I need the user to know that some functions are going on in backend not that the screen is frozen
So,I need to show a ProgressBar on click of that button inside the GridView
How to do that??
I was searching for this for a while finally found it ,
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:GridView ID="Gridview" OnRowDataBound="Gridview_RowDataBound" OnRowCommand="Gridview_RowCommand" runat="server" Style="text-align: center" ShowFooter="true" Width="99%"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Total Customers" HeaderStyle-BackColor="#99CCCC">
<ItemTemplate>
<asp:Button ID="btnCombine" CssClass="btn-primary btn" Text="Combine"
Font-Bold="true"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CommandName="More"
Style="padding-top: 1%; padding-bottom: 1%; margin-top: 1px; margin-bottom: 1px" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
<ProgressTemplate>
<img src="images/progress_bar.gif" style="max-width: 250px" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddi" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
just name the same ID of the button u use in controlID of the AsyncPostBackTrigger and AssociatedUpdatePanelID same name u put the GridView
I am having a problem when I mark some checkbox checked in a grid view, the page itself will jump back to the top instead of staying at the same position when auto post back. Here is how I set up my grid view:
<UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<!-- COLLAPSIBLE PANEL EXTENDER -->
<asp:Panel ID="pHeader1" runat="server" CssClass="cpHeader">
<!-- Collapsible panel extender header -->
<div class="form-group" style="background-color: #ffb848; height: 30px; vertical-align: middle">
<div class="col-md-3">
<div style="float: left; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblCategory" Text='<%# DataBinder.Eval(Container.DataItem, "categoryName") %>' runat="server" />
</div>
</div>
<div class="col-md-9">
<div style="float: right; color: White; padding: 5px 5px 0 0">
<asp:Label ID="lblHeaderText1" runat="server" />
</div>
</div>
<div style="clear: both"></div>
</div>
</asp:Panel>
<!-- Collapsible panel extender body -->
<asp:Panel ID="pBody1" runat="server" CssClass="cpBody">
<asp:Label ID="lblBodyText1" runat="server" />
<!-- Grid view to show products based on each category -->
<asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" Width="998px" CellPadding="4" ForeColor="#333333" GridLines="None" ShowHeader="False" DataKeyNames="id">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="cbCheckRow" runat="server" AutoPostBack="true"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Name" ItemStyle-Width="650px" />
<asp:BoundField DataField="inventoryQuantity" HeaderText="Total Unit" />
<asp:TemplateField HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="200px">
<ItemTemplate>
<asp:TextBox ID="tbQuantity" runat="server" Width="40" Text="0" OnTextChanged="tbQuantity_TextChanged" AutoPostBack="true"/>
<asp:Label ID="lblCheckAmount" runat="server" ForeColor="#a94442"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#ffb848" ForeColor="White" />
<PagerStyle BackColor="#d8d8d8" ForeColor="#333333" HorizontalAlign="Left" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpe1" runat="server" TargetControlID="pBody1" CollapseControlID="pHeader1"
ExpandControlID="pHeader1" Collapsed="true" TextLabelID="lblHeaderText1" CollapsedText="Show"
ExpandedText="Hide" CollapsedSize="0"
ScrollContents="false">
</asp:CollapsiblePanelExtender>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</UpdatePanel>
I've added the update panel. So far from my research, I know that we should use update panel to prevent the page jump up when auto post back. However, mine does not work. Any guides?
Thanks in advance.
You can use the MaintainScrollPositionOnPostback attribute of page Directive. See Sample below:
<%# Page MaintainScrollPositionOnPostback="true" %>
I have a UserControl which is a nested GridView (facebook like wall), i want to load posts on scrolling down. I am following this article..
CLICK ME
The problem is that this method is using the first column's last row to get the last productid
something like this
var lastProductId = $("#GridViewUserScraps tr:last").children("td:first").html();
But in my case i am not displaying any id in any of the columns of the UserControl's GridView though i have a ScrapId column(primary key) in database. How can i load Posts on scrolling down? how can i make it work?
My UserControl:
<div id="divProducts" style="height:700px;overflow:auto">
<asp:GridView ID="GridViewUserScraps" ItemStyle-VerticalAlign="Top" AutoGenerateColumns="False"
GridLines="None" Width="100%" ShowHeader="False" runat="server" AlternatingRowStyle-BackColor="#A5A5A5"
CellPadding="4" ForeColor="#333333" DataKeyNames="ScrapId" OnRowCommand="GridViewRowCommand">
<Columns>
<asp:TemplateField>
<FooterTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">Load More</asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<table align="left" cellpadding="1" cellspacing="2">
<tr>
<td>
<a href='<%#getUserHREF(Container.DataItem)%>'>
<img align="middle" src='<%#getSRC(Container.DataItem)%>' border="0" width="50px" /></a>
</td>
<td>
</td>
</tr>
</table>
<div align="justify">
<b>
<%#DataBinder.Eval(Container.DataItem,"firstname")%>
<div>
<asp:HiddenField ID="hiddenLastProductID" runat="server" Value='<%# Eval("id") %>' />
</div>
</b>
<br />
<%#DataBinder.Eval(Container.DataItem, "Message")%>
<br />
<asp:Image ID="Image" runat="server" ImageUrl='<%# Eval("url") %>' style="max-width:500px;" />
</div>
<span class="SmallBlackText">Posted On: </span>
<asp:Label ID="lblSendDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"SendDate")%>'></asp:Label>
</span>
<br />
<%-- <asp:LinkButton ID="lnklike" runat="server"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
CommandName="LikeCmd">Like</asp:LinkButton>
<asp:LinkButton ID="lnkunlike" runat="server">unlike</asp:LinkButton>--%>
<asp:ImageButton ID="lnklike" runat="server" ImageUrl="~/Images/thumbsup.png" Height="20px"
Width="20px" CommandName="like" CommandArgument='<%# Eval("ScrapId")%>' />
<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnklike" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Controls_GetUserScraps.abc((int)Eval("ScrapId")) %>' />
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:Label ID="Label1" runat="server" Text='<%# WebPageName.StaticMethodName((int)Eval("ScrapId")) %>' />--%>
<asp:ImageButton ID="lnkunlike" runat="server" CommandArgument='<%# Eval("ScrapId")%>'
CommandName="unlike" Height="20px" ImageUrl="~/Images/thumbsdown.png" Width="20px" />
<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkunlike" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Controls_GetUserScraps.xyz((int)Eval("ScrapId")) %>'></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:LinkButton ID="lnkcomment" runat="server">Comment</asp:LinkButton>
<asp:LinkButton ID="lnkviewall" runat="server" CommandName="viewall" CommandArgument='<%# Eval("ScrapId")%>'>View All</asp:LinkButton>
<br />
<asp:Panel ID="Pnlchildgrid" runat="server">
<asp:GridView ID="childgrid" runat="server" AutoGenerateColumns="False" OnRowCommand="childgrid_RowCommand"
Style="width: 450px; float: right;">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table align="left" cellpadding="1" cellspacing="2">
<tr>
<td>
<a href='<%#getUserHREF(Container.DataItem)%>'>
<img align="middle" src='<%#getSRC(Container.DataItem)%>' border="0" width="30px" /></a>
</td>
<td>
</td>
</tr>
</table>
<div align="justify">
<b>
<%#DataBinder.Eval(Container.DataItem, "firstname")%></b><br />
<%#DataBinder.Eval(Container.DataItem, "commentmsg")%>
<br />
</div>
<span class="SmallBlackText">Posted On: </span>
<asp:Label ID="lblSendDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"SendDate")%>'></asp:Label>
</span>
<br />
<asp:ImageButton ID="lnklike" runat="server" Height="20" Width="20" CommandName="childlike"
CommandArgument='<%# Eval("commentid")%>' ImageUrl="~/Images/thumbsup.png" />
<asp:Label ID="Label1" runat="server" Text='<%# Controls_GetUserScraps.abc1((int)Eval("commentid")) %>' />
<asp:ImageButton ID="lnkunlike" runat="server" CommandArgument='<%# Eval("commentid")%>'
CommandName="childunlike" Height="20" ImageUrl="~/Images/thumbsdown.png" Width="20" />
<asp:Label ID="Label2" runat="server" Text='<%# Controls_GetUserScraps.xyz1((int)Eval("commentid")) %>'></asp:Label>
<%-- <asp:LinkButton ID="lnkcomment" runat="server">Comment11111</asp:LinkButton>--%>
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="txtcomment" runat="server" Width="500px" ></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Comment" CommandName="comment" CommandArgument='<%# Eval("ScrapId")%>' />
</asp:Panel>
</asp:Panel>
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
I'm trying to get the value from detailsview to formview. I want to set the Book ID/ISBN in formview insert textbox to Book ID/ISBN value from detailsview.
Here's a sample of my code:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
CellPadding="4" DataKeyNames="bookid" DataSourceID="detailsDataSource"
ForeColor="#333333" GridLines="None" Height="50px" Width="">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<RowStyle BackColor="#EFF3FB" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<FooterTemplate>
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="reservationid" DataSourceID="reserveDataSource"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="Reserved by"
SortExpression="EmployeeID" />
<asp:BoundField DataField="reservedate" HeaderText="Reserved date"
SortExpression="reservedate" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="reservationid"
DataSourceID="reserveDataSource">
<EditItemTemplate>
reservationid:
<asp:Label ID="reservationidLabel1" runat="server"
Text='<%# Eval("reservationid") %>' />
<br />
bookid:
<asp:TextBox ID="bookidTextBox" runat="server" Text='<%# Bind("bookid") %>' />
<br />
EmployeeID:
<asp:TextBox ID="EmployeeIDTextBox" runat="server"
Text='<%# Bind("EmployeeID") %>' />
<br />
reservedate:
<asp:TextBox ID="reservedateTextBox" runat="server"
Text='<%# Bind("reservedate") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Book ID/ISBN:
<asp:TextBox ID="bookidTextBox" runat="server"
Text='<%# Bind("bookid") %>'/>
<br />
Employee ID:
<asp:TextBox ID="EmployeeIDTextBox0" runat="server"
Text='<%# Bind("EmployeeID") %>' />
<br />
Reserve date:
<asp:TextBox ID="reservedateTextBox0" runat="server"
Text='<%# Bind("reservedate") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Reserve" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
So what I'm trying to do is when a user click the Insert/Reserve book linkbutton the Book ID/ISBN is already set to the Book ID/ISBN in formview insert mode as default.
Any help would be much appreciated ;)
Thanks in advance.
Can you try and check the DetailsView1.SelectedValue
<asp:TextBox ID="bookidTextBox" runat="server"
Text='<%# DetailsView1.SelectedValue %>'/>
Edit:
Now if you want to bind that value to your Insert function of your DetailsView, it will not behave like the other control, since you are using the Bind method for the other control and it provides two way binding.
Now you need to pass that value to inserting evet of DetailsView like as we are assigning values using DetailsView1.SelectedValue but not binding the value.
I hope you understand this theory.
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
{
e.Values["bookid"] = ((TextBox)DetailsView1.FindControl("bookidTextBox")).Text;
}