Ajaxtoolkit combobox in gridview - c#

I'm having UI problems with ajaxtoolkit's combo box inside gridview.
<asp:Gridview Id="grv" runat="server" AutoGenerateColumns="False" CellPadding="4">
<Columns>
<asp:TempalteField>
<ItemTemplate>
<cc1:ComboBox ID="cmbGrdOrigin" runat="server" AutoCompleteMode="Suggest" Visible="false" DropDownStyle="DropDown"
AutoPostBack="true">
<asp:ListItem Text="" Value="" />
<asp:ListItem Text="Domestic" Value="Domestic" />
<asp:ListItem Text="Foreign" Value="Foreign" />
</cc1:ComboBox>
</ItemTemplate>
<asp:TempalteField>
</Columns>
</asp:Gridview>
The problem is the list of items are not showing. The combobox item list does not overlap with the cell below it.
Added photo for reference. all the combobox on the grid does not work https://drive.google.com/open?id=0B4JBZR0AZcx9WjNkbjM5UkZ1Y2c

Related

Saving radiobutton value to Database

Im trying to take some selected value to use it in an insert method I have to the database (this is working with given vaalues), now I want to give to take the value from a form. Everything's fine but the radio buttons... I do not know how to take the value :P.
Here it is:
<tr>
<td>Oral/Written Communications:</td>
<td>
<asp:RadioButton ID="form1_1" GroupName="form1" runat="server" Text="1" />
<asp:RadioButton ID="form1_2" GroupName="form1" runat="server" Text="2" />
<asp:RadioButton ID="form1_3" GroupName="form1" runat="server" Text="3" />
<asp:RadioButton ID="form1_4" GroupName="form1" runat="server" Text="4" />
<asp:RadioButton ID="form1_5" GroupName="form1" runat="server" Text="5" />
<br /></td>
</tr>
And in the backend...
int selected = form1.value
This is not working... Not even recognizing the form1. etc.... How can I handle this?
EB.
When you work with a RadioButton control, each one of them is a separate control and you need to check them like this:
string selectedValue;
if (form1_1.Checked)
selectedValue = form1_1.Text;
else if (form1_2.Checked)
selectedValue = form1_2.Text;
...
You can also go after the Request.Form collection, but I don't find it to be easy to use with RadioButton controls.
Maybe the easiest thing, if you can change the code slightly, is to use a RadioButtonList control:
<asp:RadioButtonList ID="form1list" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Text="1" />
<asp:ListItem Text="2" />
<asp:ListItem Text="3" />
<asp:ListItem Text="4" />
<asp:ListItem Text="5" />
</asp:RadioButtonList>
Then you can simply refer to the control as a whole:
form1list.SelectedValue

ajax calendar not displaying in child gridview

Ajax Calendar not displaying in child GridView
<asp:GridView ID="GVCollapse" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="Show_Hide_ChildGrid" ImageUrl="~/images/plus.png" CommandArgument="Show" Height="20" Width="20" />
<asp:Panel ID="pnlOrders" runat="server" Style="display: none;">
<asp:GridView ID="gvOrders" runat="server">
<asp:TemplateField HeaderText="Dispatch Date">
<ItemTemplate>
<asp:TextBox Width="90px" ID="txtDispatchDate" runat="server" Text=""></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
PopupButtonID="txtDispatchDate" TargetControlID="txtDispatchDate">
</ajaxToolkit:CalendarExtender>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Ajax Calendar is not working in child gridview whereas I did the same thing with parent gridview then it's working well
is Ajax calendar not working with child gridview?? or I did any mistake. I posted my design code

Horizontal scrollbar for a GridView, inside a Div, inside a Panel, inside a Div

Pretty convoluted, but I tried the old overflow-x:auto inside the Div above the GridView and it didn't work. Anyone have any other solutions? I'll try to keep the code to the relevant stuff, so my ASP looks something like this:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="MainDiv" style="height:500px; margin-left:20px;">
<asp:Panel runat="server" ID="ShowDiv1" Visible="false" BorderStyle="Solid" BorderWidth="0" Width="440px" Height="530px" style="margin-left:20px;">
<asp:DropDownList ID="ddlStatusCode" runat="server" OnSelectedIndexChanged="ddlStatusCode_OnSelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Value="1"> Open </asp:ListItem>
<asp:ListItem Value="2"> Pended for Source Documents </asp:ListItem>
<asp:ListItem Value="3"> Send to CSE </asp:ListItem>
<asp:ListItem Value="4"> Send to Auditor </asp:ListItem>
<asp:ListItem Value="5"> Assigned </asp:ListItem>
<asp:ListItem Value="6"> Question to TC </asp:ListItem>
</asp:DropDownList>
<!-- Leads: 1 -->
<div id="divGrid_Open" runat="server" style='width:1350px; height:320px; overflow-x:auto'>
<asp:GridView ID="DataGrid_Open" runat="server"
AllowSorting="True" AutoGenerateColumns="False" ShowFooter ="false" CellPadding="0"
CssClass="hoverTable"
HeaderStyle-BackColor="#5D7B9D" HeaderStyle-BorderColor="#4DA6A6" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="x-Small" itemstyle-font-size="x-small" EditItemStyle-font-size="x-small"
FooterStyle-BackColor="#5D7B9D" FooterStyle-BorderColor="#4DA6A6" FooterStyle-ForeColor="White"
DataKeyNames="Audit_Number"
OnRowCancelingEdit="DataGrid_Open_CancelCommand"
OnRowDataBound="DataGrid_Open_RowDataBound"
OnDataBound="DataGrid_Open_OnDataBound"
OnRowEditing="DataGrid_Open_EditCommand"
OnRowUpdating="DataGrid_Open_UpdateCommand">
<Columns>
<asp:TemplateField HeaderText="Audit <br />Number" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label ID="I_Open_AuditNbr" runat="server" Width="60px" Text='<%#Eval("Audit_Number") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="EI_Open_AuditNbr" runat="server" Width="60px" Text='<%#Eval("Audit_Number") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="F_Open_AuditNbr" runat="server" Width="60px" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
ETC....
</Columns>
</asp:GridView>
<asp:Label ID="lblEmpty1" runat="server" Visible="false" Style="font-weight:bold; font-size:large;"></asp:Label>
</div>
</asp:Panel>
</div>
</asp:Content>

Conflicts between multiple gridviews

I have multiple gridviews on one page. For each gridview, there are two ways to insert a new record. One is through FooterTemplate of a TemplateField when the gridview has data and the other through EmptyDataTemplate when the gridview is empty.
By itself, the inserts work well. However, if another gridview is empty, then by default, the insert portion in its EmptyDataTemplate is displayed. When this is displayed, I can't get the FooterTemplate of another gridview to display. That portion is inaccessible until I get rid of the EmptyDataTemplate by forcing an insert.
<asp:Button ID="btnAddNewDomSoilType" runat="server" Text="Add new record" CssClass="btnNewRecord" OnClick="addNewDomSoilType" />
<asp:GridView ID="gvDomSoilType" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="dsDomSoilType" CssClass="data"
AllowSorting="True" onrowcommand="gvDomSoilType_RowCommand" DataKeyNames="HabitatObsSubstrateID, HabitatObservationID, SubstrateID" >
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete"
OnClientClick="return confirm('Are you sure?');"
AlternateText="Delete" ForeColor="Blue"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsertSubmit" runat="server" Text="Submit" CommandName="SubmitInsert" CssClass="btnInsertSEID" />
<asp:Button ID="btnInsertCancel" runat="server" Text="Cancel" CommandName="CancelInsert" CssClass="btnInsertSEID" CausesValidation="false" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Substrate" SortExpression="Substrate">
<FooterTemplate>
<asp:DropDownList ID="ddlSoilType" runat="server"
DataSourceID="dsDomSoilType_Insert" DataTextField="Description"
DataValueField="Value" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Substrate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:Label ID="Label4" runat="server" Text="Substrate: " CssClass="insertLabel"></asp:Label>
<asp:DropDownList ID="ddlSoilType2" runat="server"
DataSourceID="dsDomSoilType_Insert" DataTextField="Description"
DataValueField="Value" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnInsertEmpty" runat="Server" Text="Insert" CommandName="EmptyInsert" UseSubmitBehavior="False" />
</EmptyDataTemplate>
</asp:GridView>
<asp:Button ID="btnAddNewVegCover" runat="server" Text="Add new record" CssClass="btnNewRecord" OnClick="addNewVegCover" />
<asp:GridView ID="gvVegCover" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="dsVegCover" CssClass="data"
AllowSorting="True" onrowcommand="gvVegCover_RowCommand" DataKeyNames="HabitatObsVegID">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete"
OnClientClick="return confirm('Are you sure?');"
AlternateText="Delete" ForeColor="Blue"></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsertSubmit" runat="server" Text="Submit" CommandName="SubmitInsert" CssClass="btnInsertSEID" />
<asp:Button ID="btnInsertCancel" runat="server" Text="Cancel" CommandName="CancelInsert" CssClass="btnInsertSEID" CausesValidation="false" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="HabitatVegetationType" SortExpression="HabitatVegetationType">
<FooterTemplate>
<asp:DropDownList ID="ddlVegType" runat="server"
DataSourceID="dsVegType_Insert" DataTextField="Description"
DataValueField="Value" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblVegType" runat="server" Text='<%# Bind("HabitatVegetationType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VegetationTypePercent" SortExpression="VegetationTypePercent">
<FooterTemplate>
<asp:TextBox ID="txtVegTypePercent" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblVegTypePercentage" runat="server" Text='<%# Bind("VegetationTypePercent") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:Label ID="Label2" runat="server" Text="Vegetation Type:" CssClass="insertLabel"></asp:Label>
<asp:DropDownList ID="ddlVegType2" runat="server"
DataSourceID="dsVegType_Insert" DataTextField="Description"
DataValueField="Value" AppendDataBoundItems="true">
<asp:ListItem Text="" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label5" runat="server" Text="Percenttage:" CssClass="insertLabel"></asp:Label>
<asp:TextBox ID="txtVegTypePercent2" runat="server"></asp:TextBox>
<asp:Button ID="btnInsertEmpty" runat="Server" Text="Insert" CommandName="EmptyInsert" UseSubmitBehavior="False" />
</EmptyDataTemplate>
</asp:GridView>
Code behind:
protected void addNewDomSoilType(object sender, EventArgs e)
{
gvDomSoilType.ShowFooter = true;
}
protected void addNewVegCover(object sender, EventArgs e)
{
gvVegCover.ShowFooter = true;
}
I know my explanation is a bit confusing. Let me know what doesn't make sense and I'll try to clarify. Thanks for looking.
These two gridviews shouldn't impact each other. I think it might be the PostBack that is messing up the state of the webpage. On the PageLoad do Page.IsPostBack false and then populate the data. Make sure the events are hooked up to the right GridView.

GridView paging in UpdatePanel

I have an UpdatePanel and a GridView within it. I have a problem with paging: when I press Next button, grdUsers_PageIndexChanging() is not called, so the page stays 1, and if previously I changed selection in ddlPageSize, now it goes back to the initial selection.
Also, if I am on the first page, the Previous button is not disabled, and pressing it causes Out Of Range error.
What am I doing wrong?
Thanks.
<asp:UpdatePanel ID="upnlUsers" runat="server" ChildrenAsTriggers="true" UpdateMode="Always" >
<ContentTemplate>
<div style="height:400px; width:1500px; overflow:auto;">
<asp:GridView ID="grdUsers" runat="server" AllowPaging="True" ShowHeader="false" ShowFooter="true"
AutoGenerateColumns="false" CssClass="largegridview largegridview_td"
Width="1480px" Height="100%" PageSize="100" DataKeyNames="ID" EnableSortingAndPagingCallbacks="false"
onpageindexchanging="grdUsers_PageIndexChanging"
onrowdatabound="grdUsers_RowDataBound">
<AlternatingRowStyle CssClass="alternatingrowstyle" />
<Columns>
<asp:TemplateField HeaderText="User Name" SortExpression="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" SortExpression="LastName">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server" Text='<%# Eval("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" SortExpression="FirstName">
<ItemTemplate>
<asp:Label ID="lblFirstName" runat="server" Text='<%# Eval("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" SortExpression="Email">
<ItemTemplate>
<asp:Label ID="lblEmail" runat="server" Text='<%# Eval("Email") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pagerstyle" />
<PagerTemplate>
<asp:Label ID="Label1" runat="server" Text="Show rows:" />
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem Value="20" />
<asp:ListItem Value="50" />
<asp:ListItem Value="100" />
</asp:DropDownList>
Page
<asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true"
OnTextChanged="GoToPage_TextChanged" CssClass="gotopage" />
of
<asp:Label ID="lblTotalNumberOfPages" runat="server" />
<asp:Button ID="btnPrev" runat="server" CommandName="Page"
ToolTip="Previous Page" CommandArgument="Prev" CssClass="previous" />
<asp:Button ID="btnNext" runat="server" CommandName="Page" ToolTip="Next Page"
CommandArgument="Next" CssClass="next" />
</PagerTemplate>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Agreed, I tested the code, and grdUsers_PageIndexChanging() is called on mine.
Dear Friend
their is in build paging in the gridview if you want your own paging style then you have to implement your own paging through PageDataSource Class.
Click to view code
this link provide you how to implement the paging in the Datalist and Repeater through same way you will implement the paging in grid view .
Then no pageindex change event will fired in the gridview.
I don't think you are doing anything wrong; it may not actually fire the PageIndexChanged event, it probably fires the RowCommand event. Attach to the ItemCommand event and that will receive the event.
HTH.

Categories

Resources