Selected Drop down values are getting NULL but when i try to populate the text i am able to get the values.
HTML Code:
<div class="form-group">
<label>Indent No <font class="star_color"> * </font> </label>
<asp:TextBox ID="txtindentNo" runat="server" Class="form-control"
OnTextChanged="txtindentNo_TextChanged"></asp:TextBox>
</div>
<div class="form-group">
<label>Select Item <font class="star_color"> * </font> </label>
<asp:DropDownList ID="ddlItem" runat="server" class="form-control" AutoPostBack="true" OnSelectedIndexChanged="ddlItem_SelectedIndexChanged">
</asp:DropDownList>
</div>
<asp:TemplateField HeaderText="Indent Number " ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:Label ID="lblIndentNo" runat="server" Text='<%#Eval("IndentNumber") %>' Font-Size="Small"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%#Eval("SeedItemNameEng") %>' Font-Size="Small"></asp:Label>
<asp:HiddenField ID="hdnItem" runat="server" Value='<%# Bind("SeedItemID") %>' />
</ItemTemplate>
</asp:TemplateField>
Code:
txtindentNo.Text = ((Label)grdItems.Rows[IndexValue].FindControl("lblIndentNo")).Text.Trim();
ddlItem.SelectedValue = ((Label)grdItems.Rows[IndexValue].FindControl("lblItem")).Text.Trim();
Related
I'm using a datalist control to show product details before adding to cart. But here add to cart button is not working. How can I resolve this problem?
Here is the code of datalist control
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="DataList1_ItemCommand">
<ItemTemplate>
<div class="container" style="z-index:-1;">
<div class="wrapper" style="margin-left:400px;" >
<div class="databox effect1">
<div id="imagedata" style="padding:10px">
<asp:Image ID="product_imageLabel" runat="server" Height="300px" Width="300px"
ImageUrl='<%# "data:Image/png;base64,"
+ Convert.ToBase64String((byte[])Eval("product_image")) %>'/>
</div>
<div style="margin-top:-300px;margin-left:310px;padding:10px">
<asp:Label ID="product_nameLabel" runat="server" Text='<%# Eval("product_name") %>' Font-Size="XX-Large" Font-Bold="True" />
<br/>
<asp:Label ID="product_compositionLabel" runat="server" Text='<%# Eval("product_composition") %>' Font-Size="Larger"/>
<br/>
<asp:Label ID="brand_nameLabel" runat="server" Text='<%# "Brand Name : "+Eval("brand_name") %>' Font-Size="Larger" />
<br/>
<asp:Label ID="product_stock_unitLabel" runat="server" Text='<%# Eval("product_stock_unit")+" of "+Eval("product_quantity")+" "+Eval("product_quantity_unit") %>' Font-Size="Larger"/>
<br/>
<asp:Label ID="product_priceLabel" runat="server" Text='<%# "MRP ₹ "+Eval("product_price") %>' ForeColor="#0E8CE4" Font-Size="Larger" />
<br/>
<br/>
<asp:Label ID="Label_product_code" runat="server" Text='<%# "Product Code : "+Eval("product_code") %>' Font-Size="Larger"/>
<br/>
<asp:Button ID="Button_addtocart" runat="server" Text="Add to cart" CssClass="btn third" CommandName="addtocart" CommandArgument='<%# Eval("product_code")%>' />
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
Here is the code of c# against OnItemCommand handler
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "addtocart")
{
ClientScript.RegisterStartupScript(this.GetType(), "randomtext", "not_login()", true);
}
}
Add
onclick = "DataList1_ItemCommand"
in your HTML button code
because onclick Event Main Tips. The "onclick" event occurs when the user clicks on an element. It runs a specified line of code when you click an HTML object that has the “onclick” attribute. The event can be triggered by "object.onclick" or "object.addEventListener".
I am creating a web app in C#, I have a dropdownlist like this
<asp:DropDownList ID="droptaskrpt" AutoPostBack="true" CssClass="form-control" OnTextChanged="droptaskrpt_TextChanged" runat="server">
<asp:ListItem Selected="True">Select</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
<asp:ListItem>Quarterly</asp:ListItem>
<asp:ListItem>Half Yearly</asp:ListItem>
<asp:ListItem>Yearly</asp:ListItem>
</asp:DropDownList>
If a user selects quarterly, the same data should be re-insert into the table with same value after a quarter.
I am not able to understand what I need to do here:
I will write the code on pageload
how can I validate the quarter?
how can I insert the same data into the table?
I need your help
<div class="panel-body" style="min-height: 500px;">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6">
<div class="form-group" style="margin-top: 2px">
<asp:HiddenField ID="hfTask" runat="server" />
<asp:HiddenField ID="hfParentId" runat="server" />
<%--<asp:CheckBox ID="chkmulti" runat="server" Text="Assign to Group" AutoPostBack="true" ValidationGroup="grp" />--%>
<br />
<div runat="server" id="divuserSelect">
<asp:DropDownList ID="ddlUser" runat="server" CssClass="form-control"></asp:DropDownList>
</div>
<div runat="server" id="divmultiSelect" visible="false">
<asp:TextBox ID="txtCustomer" Text="Select Customers" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Panel ID="PnlCust" runat="server" CssClass="PnlDesign">
<asp:CheckBoxList ID="cblCustomerList" runat="server">
<asp:ListItem>Customer One</asp:ListItem>
<asp:ListItem>Customer Two</asp:ListItem>
<asp:ListItem>Customer Three</asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
<asp:PopupControlExtender ID="PceSelectCustomer" runat="server" TargetControlID="txtCustomer"
PopupControlID="PnlCust" Position="Bottom">
</asp:PopupControlExtender>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
Task Title
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtTaskTitle"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtTaskTitle" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group" style="margin-top: 7px">
Start Date
<asp:TextBox ID="txtStartDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtStartDate" Format="dd MMM yyyy"></asp:CalendarExtender>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
Start Time
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtStartTime"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtStartTime" runat="server" CssClass="form-control"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="txtStartTime" MaskType="Time" AcceptAMPM="true"
Mask="99:99" ErrorTooltipEnabled="true" />
<h4 style="font-size: x-small">Type A or P to switch AM/PM</h4>
</div>
</div>
<div class="col-sm-4">
<div class="form-group" style="margin-top: 7px">
End Date
<asp:TextBox ID="txtEndDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtEndDate" Format="dd MMM yyyy"></asp:CalendarExtender>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
End Time
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtEndTime"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtEndTime" runat="server" CssClass="form-control"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="txtEndTime" MaskType="Time" AcceptAMPM="true"
Mask="99:99" ErrorTooltipEnabled="true" />
<h4 style="font-size: x-small">Type A or P to switch AM/PM</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
Description
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtDescription"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Height="100" CssClass="form-control"></asp:TextBox>
</div>
</div>
<%-- checklist for week days --%>
<div class="col-sm-6">
<h4>Task Repeat</h4>
<asp:DropDownList ID="droptaskrpt" AutoPostBack="true" CssClass="form-control" OnTextChanged="droptaskrpt_TextChanged" runat="server">
<asp:ListItem Selected="True">Select</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
<asp:ListItem>Quarterly</asp:ListItem>
<asp:ListItem>Half Yearly</asp:ListItem>
<asp:ListItem>Yearly</asp:ListItem>
</asp:DropDownList>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBoxList ID="chkWeek" Visible="false" runat="server" CssClass="checkbox-inline">
<asp:ListItem Value="1">Monday</asp:ListItem>
<asp:ListItem Value="2">Tuesday</asp:ListItem>
<asp:ListItem Value="3">Wednesday</asp:ListItem>
</asp:CheckBoxList>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBoxList ID="CheckBoxList1" Visible="false" runat="server" CssClass="checkbox-inline">
<asp:ListItem Value="4">Thursday</asp:ListItem>
<asp:ListItem Value="5">Friday</asp:ListItem>
<asp:ListItem Value="6">Saturday</asp:ListItem>
<%--<asp:ListItem Value="7">Sunday</asp:ListItem>--%>
</asp:CheckBoxList>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<br />
<div class="form-group">
<asp:FileUpload ID="fpTask" runat="server" CssClass="btn btn-block btn-warning" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="([a-zA-Z0-9\s_\\.$&*##()+\-:])+(.doc|.docx|.pdf|.jpg|.png|.jpeg|.xls|.xlsx|.txt|.gif)$"
ControlToValidate="fpTask" runat="server" ForeColor="Red" ErrorMessage="selected file is not valid"
Display="Dynamic" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
Task Priority
<asp:DropDownList runat="server" ID="ddlPriority" CssClass="form-control">
<asp:ListItem Value="Low">Low</asp:ListItem>
<asp:ListItem Value="Medium">Medium</asp:ListItem>
<asp:ListItem Value="High">High</asp:ListItem>
</asp:DropDownList>
</div>
</div>
</div>
<%--<div class="row" runat="server" id="divuser">
<div class="col-sm-6">
<div class="form-group">
User Feedback
<asp:TextBox ID="txtUserFeedBack" runat="server" class="form-control"></asp:TextBox>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBox ID="chkIsUserClose" runat="server" CssClass="checkbox-inline" Text="Close By User" />
</div>
</div>
</div>--%>
<%--<div class="row" runat="server" id="divadmin">
<div class="col-sm-6">
<div class="form-group">
Admin Feedback
<asp:TextBox ID="txtAdminFeedback" runat="server" class="form-control"></asp:TextBox>
</div>
</div>
<div class="col-sm-6" style="margin-top: 17px">
<div class="form-group">
<asp:CheckBox ID="chkIsAdminClose" runat="server" CssClass="checkbox-inline" Text="Close by Admin" />
</div>
</div>
</div>--%>
<%--<div class="row" runat="server" id="divrating">
<div class="col-sm-6">
<div class="form-group">
Rating
<asp:TextBox ID="txtRating" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
</div>--%>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<%--<asp:ImageButton ID="btnRefresh" runat="server" ImageUrl="~/Content/Images/refresh.png" />--%>
</div>
<div class="col-sm-3">
<asp:Button ID="btnUpdate" runat="server" CssClass="btn btn-primary btn-lg" Text="Update" ValidationGroup="OnUpdate" OnClick="btnUpdate_Click" />
</div>
</div>
<div>
<asp:GridView CssClass="Grid" ID="dgvTask" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" OnPageIndexChanging="dgvTask_PageIndexChanging" OnRowDeleting="dgvTask_RowDeleting">
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskId" Text='<%# Eval("TaskAutoId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sr.No">
<ItemTemplate>
<asp:Label runat="server" ID="lblSrNo" Text='<%# Eval("SrNo") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="5%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Task">
<ItemTemplate>
<asp:Label runat="server" ID="lblTask" Text='<%# Eval("TaskName")+": "+Eval("TaskDescription") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Assign To">
<ItemTemplate>
<asp:Label runat="server" ID="lblAssignTo" Text='<%# Eval("AssignTo") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Start Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskAssignDate" Text='<%# Eval("AssignDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="End Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskEndDate" Text='<%# Eval("EndDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete" Text="Delete" CssClass="action" />
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="paging" />
</asp:GridView>
</div>
<br />
</div>
all the required html objects
I want to bind a image (which is stored in binary format column name image(varbinary)) in list view in c#..
i am trying this two but not working..
<img src='<%# string.Format("data:image/gif;base64,{0}",Convert.ToBase64String((byte[])Eval("image")))%>'/>--%>
<%--<asp:Image ID="Image10" runat="server" Height="100px" ImageUrl='<%# "ShowImage.ashx?id=" + Eval("image") %>' GenerateEmptyAlternateText="True" Visible='<%# ShowImg(Eval("image")) %>' />--%>
here is the code:
<div>
<h3 class="calDetail">Event Details</h3>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VeteransDirectoryConnectionString %>" SelectCommand=
"SELECT [EventID], [OrganizationName], [Title], [DescriptionShort], [DescriptionLong], [Location], [EventDate], [URL], (CASE WHEN URL IS NULL OR URL = '' THEN CAST(0 AS bit) ELSE CAST(1 AS bit) END) AS URLLink, [FileName], (CASE WHEN FileName IS NULL OR FileName = '' THEN CAST(0 AS bit) ELSE CAST(1 AS bit) END) AS FileLink, [EventTime],image FROM [t_Event] WHERE ([EventID] = #EventID)">
<SelectParameters>
<asp:QueryStringParameter Name="EventID" QueryStringField="eventid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<div style="padding: 0px 10px 20px 10px;">
<asp:ListView ID="ListView1" runat="server" DataKeyNames="EventID" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<span>No data for this event was found.</span>
</EmptyDataTemplate>
<ItemTemplate>
<span class="listCalLabel">Organization:</span>
<asp:Label ID="OrganizationNameLabel" runat="server" Text='<%# Eval("OrganizationName") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event:</span>
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Short Description:</span>
<asp:Label ID="DescriptionShortLabel" runat="server" Text='<%# Eval("DescriptionShort") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Long Description:</span>
<asp:Label ID="DescriptionLongLabel" runat="server" Text='<%# Eval("DescriptionLong") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Location:</span>
<asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event Date:</span>
<asp:Label ID="EventDateLabel" runat="server" Text='<%# Eval("EventDate", "{0:MM/dd/yyyy}") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event Time:</span>
<asp:Label ID="EventTimeLabel" runat="server" Text='<%# Eval("EventTime") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel"><asp:Label ID="lblURL" runat="server" Visible='<%# Eval("URLLink") %>' Text="Additional Info (website):" ></asp:Label></span>
<br />
<asp:HyperLink ID="URLHyperLink" runat="server" Text='<%# Eval("URL") %>' NavigateUrl='<%# Eval("URL") %>' Visible='<%# Eval("URLLink") %>' Target="_blank" CssClass="listLink" />
<br /><br />
<span class="listCalLabel"><asp:Label ID="lblFile" runat="server" Visible='<%# Eval("FileLink") %>' Text="Additional Info (file):"></asp:Label></span>
<br />
<asp:HyperLink ID="URLFile" runat="server" Text='<%# Eval("FileName") %>' NavigateUrl='<%# "EventFiles/" + Eval("FileName") %>' Visible='<%# Eval("FileLink") %>' Target="_blank" CssClass="listLink" />
<br /><br />
<%-- <img src='<%# string.Format("data:image/gif;base64,{0}",Convert.ToBase64String((byte[])Eval("image")))%>'/>--%>
<%--<asp:Image ID="Image10" runat="server" Height="100px" ImageUrl='<%# "ShowImage.ashx?id=" + Eval("image") %>' GenerateEmptyAlternateText="True" Visible='<%# ShowImg(Eval("image")) %>' />--%>
<br /></span>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="">
<span runat="server" id="itemPlaceholder" />
</div>
<div style="">
</div>
</LayoutTemplate>
</asp:ListView>
<asp:Button ID="btnOK" runat="server" OnClientClick="window.close(); return false;" Text="Close Event Detail" CssClass="btn btn-default" />
<br />
<br />
</div>
</div>
what should i do???
how to retrieve the image and show ina a webform ??
You can use handler to display image in gridview , your html markup look like inside
Gridview ItemTemplate set image control src as src=~/getImage.ashx?id=" + id
where getImage.ashx is your handler which return MemoryStream((byte[])img);
for more details read http://www.aspdotnet-suresh.com/2015/07/save-retrieve-display-binary-images-in-gridview-from-database-in-aspnet-csharp-vbnet.html
i am doing edit operation inside GridView using c# ASP.NET.i need when user will click on edit button all data will retrive from that row and display in text box but here i am unable to display the image.I am explaining my code below.
faq.aspx:
<div class="row">
<div class="col-md-6">
<label for="question" accesskey="T"><span class="required">*</span> Question</label>
<asp:TextBox ID="TextBox1" runat="server" size="30" value="" name="question" ></asp:TextBox>
<div id="noty" style="display:none;" runat="server"></div>
<label for="answer" accesskey="A"><span class="required">*</span> Answer</label>
<asp:TextBox ID="TextBox2" runat="server" size="30" value="" name="answer" ></asp:TextBox>
<div id="Div1" style="display:none;" runat="server"></div>
</div>
<div class="col-md-6 bannerimagefile">
<label for="insertimage" accesskey="B"><span class="required">*</span> Insert Image</label>
<asp:FileUpload runat="server" class="filestyle" data-size="lg" name="insertimage" id="FileUpload1" onchange="previewFile()" />
<label for="bannerimage" accesskey="V"><span class="required">*</span> View Image</label>
<div style="padding-bottom:10px;">
<asp:Image ID="Image3" runat="server" border="0" name="bannerimage" style="width:70px; height:70px;" />
</div>
<div class="clear"></div>
<asp:Button ID="Button1" runat="server" Text="Submit" class="submit"
onclick="Button1_Click" />
</div>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" Width="100%" CssClass="table table-striped table-bordered margin-top-zero" OnRowCommand="GridView1_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Sl No">
<ItemTemplate>
<asp:Label ID="faqid" runat="server" Text='<%#Eval("FAQ_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Question" >
<ItemTemplate>
<asp:Label ID="question" runat="server" Text='<%#Eval("Question") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Answer" >
<ItemTemplate>
<asp:Label ID="answer" runat="server" Text='<%#Eval("Answer") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image" >
<ItemTemplate>
<asp:Image ID="Image1" runat="server" border="0" name="bannerimage" style="width:70px; height:70px;" ImageUrl='<%# "/Upload/" + Convert.ToString(Eval("Image")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" >
<ItemTemplate>
<!--</i>
<i class="fa fa-times"></i> -->
<asp:HyperLink ID="HyperLink1" runat="server" data-toggle="tooltip" title="" class="btn btn-xs btn-success" data-original-title="Edit" CommandName="DoEdit" CommandArgument='<%# Eval("FAQ_ID") %>' ><i class="fa fa-edit"></i></asp:HyperLink>
<asp:HyperLink ID="HyperLink2" runat="server" data-toggle="tooltip" title="" class="btn btn-xs btn-danger" data-original-title="Delete" CommandName="DoDelete" CommandArgument='<%# Eval("FAQ_ID") %>' ><i class="fa fa-times"></i></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
faq.aspx.cs:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int faqID = int.Parse(e.CommandArgument.ToString());
switch (e.CommandName)
{
case "doEdit":
{
int index = Convert.ToInt32(e.CommandArgument);
TextBox1.Text = GridView1.Rows[index].Cells[1].Text;
TextBox2.Text = GridView1.Rows[index].Cells[2].Text;
HiddenField1.Value = GridView1.Rows[index].Cells[0].Text;
Image3.ImageUrl=
Button1.Text = "Update";
}
}
}
Here i need the image will retrive and set to image3 id.Please help me to solve this issue.
WHere is image3; it's not in your snippet. Please include that, but if it's in the grid, then you do:
var img3 = (Image)GridView1.Rows[index].Cells[X].FindControl("Image3");
img3.ImageUrl = "XYZ";
Direct references only work when on the page outside of a container. If inside a container, you have to use FindControl (such as detailsview.findcontrol) or if a repeatable list, you have to use FindControl from the row (or in the case of the grid, the cell).
Get row index like this:
GridViewRow gvr = (GridViewRow)(((HyperLink)e.CommandSource).NamingContainer);
int index= gvr.RowIndex;
// to get image url
string url = ((Image)gvr.FindControl("Image3")).ImageUrl;
Image3.ImageUrl= url;
I have 3 bootstrap tabs in a page. In the first and third tab buttons they are not working but a button in the second tab works fine. In the second tab I have an update panel to post back a dropdown because I want to show like bootstrap modal script and a button at second tab is working fine. Can you tell me why it's happening and how can I do this?
My question is very confusing to explain. I want to use about why a button in tab is not working but in the second tab is working fine. And when I do function in second tab finish a button in first tab is working. Why is happening? I am very confused. Thank you very much.
this is code in .aspx with function modal:
<div class="tab-pane fade" id="profile">
<%--modal --%>
<button type="button" id="aaa" data-toggle="modal" data-target="#download" class="btn btn-primary btn-lg">เพิ่มรายการใหม่</button>
<div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="downloadlabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="downloadlabel">
<asp:Label ID="usrl" runat="server"></asp:Label>
<br />
<asp:Label ID="detail" runat="server"></asp:Label></h4>
</div>
<div class="modal-body">
<p>
<strong>Request Section</strong><br /><br />
</p>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Panel ID="Panel1" runat ="server">
<asp:UpdatePanel ID="update" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label6" runat="server"><b>Item Code: </b></asp:Label>
<asp:TextBox ID="itm_code" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label7" runat="server"><b>Item Description: </b></asp:Label>
<asp:TextBox ID="itm_desc" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Order Category: </b></asp:Label>
<asp:DropDownList ID="ord_cat" CssClass="form-control" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ord_cat_SelectedIndexChanged">
<asp:ListItem Value="0" Text="Chosse Order Category"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Order Subcategory / Department in Lab: </b></asp:Label>
<asp:DropDownList ID="ord_subCat" CssClass="form-control" runat="server">
<asp:ListItem Value="0" Text="Chosse Order Subcategory"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label11" runat="server"><b>Billing Group: </b></asp:Label>
<asp:DropDownList ID="ord_bg" CssClass="form-control" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ord_bg_SelectedIndexChanged">
<asp:ListItem Value="0" Text="Chosse Billing Group"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label14" runat="server"><b>Billing SubGroup: </b></asp:Label>
<asp:DropDownList ID="ord_bsg" CssClass="form-control" runat="server">
<asp:ListItem Value="0" Text="Chosse Billing Sub Group"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Service Cat: </b></asp:Label>
<asp:TextBox ID="ord_svc" CssClass="form-control" runat="server"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Alias Name / Synonym in Lab: </b></asp:Label>
<asp:TextBox ID="ord_asn" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Cost Price: </b></asp:Label>
<asp:TextBox ID="ord_cp" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<div class="form-inline">
<asp:Label runat="server"><b>OPD Price: </b></asp:Label>
<asp:TextBox ID="OPD_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
<asp:Label runat="server"><b>IPD Price: </b></asp:Label>
<asp:TextBox ID="IPD_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
<asp:Label runat="server"><b>Tourist Price: </b></asp:Label>
<asp:TextBox ID="TOU_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>File upload</b></asp:Label>
<asp:FileUpload ID="fileupload" runat="server" />
<p class="help-block" style="color: #FF852C">โปรดระบุ เอกสารแนบท้ายเพิ่มเติมกรณี (ถ้ามี)</p>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Send to DF: </b></asp:Label>
<asp:RadioButtonList ID="ord_sdf" runat="server" CssClass="required">
<asp:ListItem Value="Yes" Text="Yes"></asp:ListItem>
<asp:ListItem Value="No" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ControlToValidate="ord_sdf" ErrorMessage="Please select some other choice.">
</asp:RequiredFieldValidator>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Remark: </b></asp:Label>
<asp:TextBox ID="ord_rmk" TextMode="MultiLine" CssClass="form-control" runat="server"></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btn_insert" CssClass="btn btn-danger" Text="INSERT ITEM" runat="server" OnClick="btn_insert_Click" />
<button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
code in tab 1
<div class="tab-content">
<div class="tab-pane fade in active" id="home">
<div class="search">
<div class="form-inline">
<div class="group-search">
<asp:Label ID="Label12" Text="Item Code : " runat="server" CssClass="control-label" Font-Bold ="true"></asp:Label>
<asp:TextBox ID="search_ic" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Label ID="Label13" Text="Item Description : " runat="server" CssClass="control-label" Font-Bold ="true"></asp:Label>
<asp:TextBox ID="search_id" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Button ID="btn_search" Text="Search" runat="server" CssClass="btn btn-default" OnClick="btn_search_Click" />
<asp:Label ID="txt_alert" Text="กรุณากรอก Item Code หรือ Item Description" runat="server" CssClass="form-control" Visible="false"></asp:Label>
</div>
</div>
</div>
<%--gridview for update--%>
<div class="meddle2">
<asp:GridView ID="gridview" runat="server" AutoGenerateColumns="False"
OnDataBound="gridview_DataBound"
OnRowCancelingEdit="gridview_RowCancelingEdit"
OnRowEditing="gridview_RowEditing" OnRowUpdated="gridview_RowUpdated"
CssClass="table table-hover table-striped">
<Columns>
<asp:CommandField ShowEditButton="True" HeaderStyle-BackColor="#D4E6ED" ControlStyle-CssClass="btn btn-primary" ButtonType="Button" HeaderStyle-Width="80">
<ControlStyle CssClass="btn btn-primary"></ControlStyle>
<HeaderStyle Width="80px"></HeaderStyle>
</asp:CommandField>
<asp:TemplateField HeaderText="No." HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblnum" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.num") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Code" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblIC" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.item_code") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_ic" runat="server" size="6" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.item_code") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Description" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.item_des") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_id" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.item_des") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblEOP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.eop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_eop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.eop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblEIP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.eip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_eip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.eip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblETP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.etp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_etp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.etp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNOP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.nop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_nop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.nop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNIP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.nip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_nip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.nip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNTP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ntp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_ntp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.ntp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmop" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmip" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmtp" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mtp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mtp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mtp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HiddenField ID="hdf" runat="server" />
</div>
</div>