I need to pass the querystring value, of linkbutton to iframe source here is the Code
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
Width="100%" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" DataKeyNames="ItemCode">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
<Columns>
<asp:BoundField DataField="State" HeaderText="State"/>
<asp:BoundField DataField="City" HeaderText="City"/>
<asp:BoundField DataField="LandlineNo1" HeaderText="Contact"/>
<asp:BoundField DataField="Item_name" HeaderText="Name"/>
<asp:BoundField DataField="Qty" HeaderText="qty"/>
<asp:BoundField DataField="rate" HeaderText="Amount"/>
<asp:BoundField DataField="DeliveryDate" HeaderText="Deliverydate"/>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDetails" runat="server" Text="Release" PostBackUrl='<%# "~/popup.aspx?RowIndex=" + Container.DataItemIndex %>'></asp:LinkButton>
<cc1:modalpopupextender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="lnkDetails"
CancelControlID="Button2" BackgroundCssClass="Background">
</cc1:modalpopupextender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" style = "display:none">
<iframe style=" width: 600px; height: 400px;" id="irm1" src="popup.aspx?id=<% =request.Querystring(" id=")%>" runat="server"></iframe>
<br/>
<asp:Button ID="Button2" runat="server" Text="Close" />
</asp:Panel>
how to pass the value of querystring to popup.aspx page for now its
going null
Related
Im getting this error when im trying to enable an delete button on my asp.net website, any solutions ??
error : Exception Details: System.NotSupportedException: Deleting is not supported by data source 'SqlDataSourceRegister' unless DeleteCommand is specified.
<asp:SqlDataSource ID="SqlDataSourceRegister" runat="server" ConnectionString="<%$ ConnectionStrings:RegisterConnectionString %>" SelectCommand="SELECT * FROM [Table]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSourceRegister" ForeColor="#333333" GridLines="None" Height="195px" Width="254px" DataKeyNames="Id" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" ReadOnly="True" InsertVisible="False" />
<asp:BoundField DataField="Användarnamn" HeaderText="Användarnamn" SortExpression="Användarnamn" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="Lösenord" HeaderText="Lösenord" SortExpression="Lösenord" />
<asp:BoundField DataField="Land" HeaderText="Land" SortExpression="Land" />
<asp:BoundField DataField="Fullnamn" HeaderText="Fullnamn" SortExpression="Fullnamn" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<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>
</div>
</form>
</body>
</html>
I have a ajaxtoolkit:TabContainer in my code. I put gridview inside it. but it is not showing the grid view when I run the project. gridview is fine and is showing data when it is not inside the TabContainer.
This is my aspx code:
<ajaxToolkit:TabPanel ID="tbAgency" runat="server" HeaderText="Agency" >
<ContentTemplate>
<asp:GridView ID="grAgency" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
Width="901px" style="cursor: pointer;" AllowPaging="True"
AllowSorting="True" PageSize="20">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="green" Font-Bold="True" ForeColor="White"
Font-Size="Small" HorizontalAlign="Left" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#c9d9c9" Font-Size="Small" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
<Columns>
<asp:BoundField HeaderText="Agency Name" DataField="Name"
ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Description" DataField="Description"
ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Contact Name" DataField="ContactName"
ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Contact Phone" DataField="Phone"
ItemStyle-Wrap="true" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle>
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:Button ID="btnAddAgency" Text="Add Agency" runat="server" />
<asp:TextBox ID="txtAgencySearch" runat="server" />
<asp:Button ID="btnSearchAgency" runat="server" Text="Search" />
</ContentTemplate>
</ajaxToolkit:TabPanel>
and this is my C# code that when the dropdown changes, it shows data in grid.(but grid is only visible when it is outside of the Tab, when I put in inside the Tab in disappears.
protected void ddlPartnerList_SelectedIndexChanged(object sender, EventArgs e)
{
Aid = Convert.ToInt32(ddlPartnerList.SelectedItem.Value);
if (Aid != 0)
{
Session["Aid"] = Aid;
TabContainer1.ActiveTabIndex = 0;
var AgencyList = adminmv.getAgency(Aid);
grAgency.DataSource = AgencyList;
grAgency.DataBind();
}
}
Put the GridView inside a ContentTemplate inside an UpdatePanel inside the ContentTemplate of the TabPanel and make sure you have a ToolkitScriptManager control on the page.
<tabPanel>
<contentTemplate>
<updatePanel>
<contentTemplate>
<gridview>
i have a gridview inside content page , but it always goes out of the placeholder of the master page.. i want the gridview to integrate with the width of the place holder, any help please.
I tried to change the width of the grid, but nothing happened.
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<br />
<br />
<div dir="rtl">
<h2 dir="rtl">نتائج البحث</h2>
<h3 runat="server" id="H3_NoResult" dir="rtl"></h3>
<asp:GridView ID="GV_SearchResult" runat="server" AutoGenerateColumns="False" DataKeyNames="AutoNo" DataSourceID="SDS_GetSearchResult" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="300" AllowSorting="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="AutoNo" HeaderText="رقم الطعام" InsertVisible="False" ReadOnly="True" SortExpression="AutoNo" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:HyperLinkField DataTextField="NameAr" HeaderText="اسم العربي للطعام" DataNavigateUrlFields="AutoNo"
DataNavigateUrlFormatString="FoodItem.aspx?AutoNo={0}" SortExpression="NameAr" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:HyperLinkField>
<asp:BoundField DataField="NameEn" HeaderText="الاسم الانجليزي للطعام" SortExpression="NameEn" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="NameDescAr" HeaderText="وصف الطعام بالعربي" SortExpression="NameDescAr" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="NameDescEn" HeaderText="وصف الطعام بالإنجليزي" SortExpression="NameDescEn" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="FoodCatName" HeaderText="صنف الطعام" ReadOnly="True" SortExpression="FoodCatName" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="الصورة" SortExpression="ImgLink">
<ItemTemplate>
<asp:Image ID="Img_TopicImage" AlternateText="لا يوجد صورة" runat="server" Height="70px" Width="100px" ImageUrl='<%#String.Format("../RecipeImages/{0}", Eval("ImgLink")) %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#557c12" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<asp:SqlDataSource ID="SDS_GetSearchResult" runat="server" ConnectionString="<%$ ConnectionStrings:dietdbCS %>" SelectCommand="GetFoodListTBL_By_FoodName_By_FoodDescs" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="FoodName" QueryStringField="val" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</asp:Content>
make the width gridview = 100%
<asp:GridView ID="GV_SearchResult" runat="server" AutoGenerateColumns="False" DataKeyNames="AutoNo" DataSourceID="SDS_GetSearchResult" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="300" AllowSorting="True" width="100%">
Place the gridview inside a div and giv overflow for the div as follows.
<div style="overflow-x:scroll;overflow-y:scroll;">
<asp:gridview id="grid1" runat="server" />
</div>
I am trying to have a gridview with dynamic data imported using a SqlDataSource , plus 2 TemplateFields containing 2 buttons as Accept and Decline.What I need to do is , update a specific column of the table where the records are coming from.(Change the value from Null to 1 or 0, in the column called "accepted")
Q.)I need a way to identify the row which the button will be clicked ?
(need to identify the value of access key for the particular row)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="request_no" DataSourceID="SqlDataSource1" Font-Names="Tahoma" Font-Size="Small" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="request_no" HeaderText="request_no" ReadOnly="True" SortExpression="request_no" />
<asp:BoundField DataField="employee_name" HeaderText="employee_name" SortExpression="employee_name" />
<asp:BoundField DataField="requested_date" HeaderText="requested_date" SortExpression="requested_date" />
<asp:BoundField DataField="requested_time" HeaderText="requested_time" SortExpression="requested_time" />
<asp:BoundField DataField="requested_from" HeaderText="requested_from" SortExpression="requested_from" />
<asp:BoundField DataField="requested_to" HeaderText="requested_to" SortExpression="requested_to" />
<asp:BoundField DataField="service_type" HeaderText="service_type" SortExpression="service_type" />
<asp:BoundField DataField="reason_data" HeaderText="reason_data" SortExpression="reason_data" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="AcceptRequest" runat="server" OnClick="AcceptRequest_Click" Text="Accept" CommandName="AcceptRequestcmd" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="DeclineRequest" runat="server" OnClick="DeclineRequest_Click" Text="Decline" CommandName="DeclineRequestcmd" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
You are very close, just lack CommandArgument:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="AcceptRequest" runat="server"
OnClick="AcceptRequest_Click" Text="Accept"
CommandName="AcceptRequestcmd"
CommandArgument="<%# Eval("request_no") %> />
</ItemTemplate>
</asp:TemplateField>
(assuming that request_no is the row identifier)
Then just
protected void GridView1_RowCommand(...)
{
switch ( e.CommandName )
{
case "AcceptRequestcmd" :
string rowid = e.CommandArgument;
}
}
I have this GridView that uses a custom data source:
<asp:ScriptManager ID="DateManager" runat="server" />
<asp:UpdatePanel ID="setDate" runat="server"
UpdateMode="Conditional"
ChildrenAsTriggers="true">
<ContentTemplate>
<asp:GridView ID="res" runat="server"
AutoGenerateColumns="False"
CellPadding="4"
ForeColor="#333333"
GridLines="None"
Width="600px"
AllowPaging="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Ty" HeaderText="Type" />
<asp:BoundField DataField="time" HeaderText="Time" />
<asp:BoundField DataField="duration" HeaderText="Duration" />
<asp:BoundField DataField="confirmed" HeaderText="Status" />
<asp:CommandField SelectText="SelectIt" ShowSelectButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
How can I enable multiple select on it?
You can add CheckBox near evey row like code below and select multiple lines.
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="RowLevelCheckBox" />
</ItemTemplate>
</asp:TemplateField>
For detailed information check these articles : Article1 Article2