I have a GridView with 5 fields in jqQrid
<cc1:JQGrid ID="Qgrid" runat="server" Width="700px" Height="100%"
ondatarequesting="QgridDataRequesting"
onrowediting="QgridRowEditing">
<Columns>
<trirand:JQGridColumn Searchable="true"
SearchToolBarOperation="IsEqualTo" DataType="Int"
HeaderText="Order ID" PrimaryKey="True" ></trirand:JQGridColumn>
<trirand:JQGridColumn DataField='id' Visible="False"/>
<trirand:JQGridColumn DataField='last_name' Visible="False"/>
<trirand:JQGridColumn DataField='first_name' Visible="False"/>
<trirand:JQGridColumn DataField="opinion" Editable="True" />
</Columns>
<EditInlineCellSettings Enabled="True" />
<PagerSettings NoRowsMessage="No data in grid." />
<ToolBarSettings ShowEditButton="true" ShowRefreshButton="True" />
</cc1:JQGrid>
I wrote logic for events gridDataRequesting and gridRowEditing and now my license has expired
I want to write a simple gridview, but I don't know how to add a column with textbox's.
After leaving a textbox I want to I call "function grid RowEditing" (which executes a sql updating with the value from textbox)
Do you know any free plugin nearly like JqGrid?
If you are referring to editing the items in the gridview using text boxes, then you can check out this link. Here edit links are present that helps you in editing rows inline. The grid needs to be associated with an UpdateCommand. In your case that would execute the sql update. An alternative to gridRowEditing.
As for populating the data in the gridview, it can be done in the page load event of the aspx page. A possible alternative to gridDataRequesting in jqGrid.
Related
I have a long-term project (approx 9 years of continual use so far) that uses gridviews in several pages. The gridviews are used to display abbreviated summary details only, each with separate editing forms (hidden until called) being used.
I'm not using in-grid editing as the editing is too complex. The editing form is called and revealed either by the separate Add button or by a row's Edit linkbutton (using a ButtonField).
This approach has worked perfectly for several years upto and including .net 3.5. However, after a recent attempt to upgrade the project platform to .net 4 I found the grids entered in-line edit mode when:
The gridview Edit link button is clicked, and then
The edit form is dismissed by either the cancel button or save button methods
The gridview does not enter the editmode until after the actual editing form is dismissed. If the Save method is invoked, then a full re-bind of the gridview is involved, but it still enters editmode!
I have tried setting the grid's EditIndex to -1, but this doesn't make any difference.
If I reset the compilation target to 3.5 the grids all behave as expected again. I don't have this problem with projects originally started as .net 4 projects.
Partial UI code:
<asp:Button ID="cmdAdd" runat="server" Text=" Add " />
<asp:GridView ID="gvWPHA" runat="server" AutoGenerateColumns="false"
DataKeyNames="PORLID" AllowSorting="false"
EmptyDataText="No records yet" EmptyDataRowStyle-CssClass="qansYes">
<HeaderStyle CssClass="gvhead" />
<RowStyle CssClass="TRPrime" />
<AlternatingRowStyle CssClass="TRAlt" />
<SelectedRowStyle CssClass="TRSelect" />
<Columns>
<asp:ButtonField ButtonType="Link" Text="Edit" CommandName="Edit" />
<asp:BoundField DataField="PORLID" HeaderText="Record #" />
<asp:BoundField DataField="DateOfAppt" SortExpression="DateOfAppt" HeaderText="Appt Date" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="OutcomeDesc" HeaderText="Outcome" />
<asp:ButtonField ButtonType="Link" Text="Delete" CommandName="Delete" />
</Columns>
</asp:GridView>
<asp:UpdatePanel ID="upEdit" runat="server">
<ContentTemplate>
... Editing Form markup and validation, cancel button, save button, etc ...
</ContentTemplate>
</asp:UpdatePanel>
Has anyone else experienced this problem?
There was a change in the GridView's behavior in .NET 4.0. The Microsoft Connect bug report is here:
https://connect.microsoft.com/VisualStudio/feedback/details/554166/gridview-sets-editindex-property-when-in-previous-net-versions-it-didnt
For displaying data in our application I've use GridView with the following markup:
<asp:GridView ID="listGridView" runat="server" DataSourceID="GridDataSource"
AllowPaging="True" AllowSorting="True"CssClass="gridview" AutoGenerateColumns="false" >
<Columns>
<asp:DynamicField DataField="App_Contact" />
<asp:DynamicField DataField="OldContact" />
<asp:DynamicField DataField="OldContactType" />
<asp:DynamicField DataField="NewContact" />
<asp:DynamicField DataField="NewContactType" />
<asp:DynamicField DataField="action_id" />
</Columns>
</asp:GridView>
Control with above grid is used as List control and display data in read only mode.
I would like add text box for each row and button for text box values saving.
I've create dynamic filed control (inherited from FieldTemplateUserControl), but control always invoked in readonly mode and property Mode always equal Read and control does not save data in databound source.
May be is exists any another way to add editable column to dynamic data List control?
The IDataBoundControl, IDataBoundListControl, IDataBoundItemControl and the IFieldControl interfaces expose the common properties that are required for Dynamic Data support. If you are creating a custom data-bound control that will work with Dynamic Data, you can implement these interfaces instead of deriving from the DataBoundControl class.
I was wondering if any one could shed some light on property in the GridView. As far as I know, if no records are found, the text message inside
will be displayed, when the GridView control is bound to data. Actually, it’s working fine, but it works even if the record is found, too.
Currently, the datagridview is like this:
<asp:GridView ID="gvNomineeSearchResults" runat="server" DataKeyNames="ind_cst_key"
AutoGenerateColumns="false" AutoGenerateSelectButton="true"
OnSelectedIndexChanging="gvNomineeSearchResults_SelectedIndexChanged" OnRowCreated="gvNomineeSearchResults_RowCreated"
CssClass="selectedItems nominee" Width="100%" Caption="Search Results">
<Columns>
<asp:BoundField DataField="lastname" HeaderText="Last Name" NullDisplayText=" " />
<asp:BoundField DataField="firstname" HeaderText="First Name" NullDisplayText=" " />
</Columns>
<EmptyDataTemplate>
<p>Your search did not return any active AIAA Associate Fellows or did not find an email address on file for the individual you are searching for.</p>
</EmptyDataTemplate>
Any idea why the message is still showing even if records are found ?
Just Check the condition its correctly working or not.
Check the condition Gridview while Binding.
if(Dataset1.Items.count>0)
{
//Put your codes Here
}
Before Binding a Data to the Gridview Clear the Gridview Items.
Gridview1.Items.Clear();
Hope this may helpful....
I'm trying to make a page where information from the database are displayed on a page. For this, I'm using a Gridview control. The data displays fine, but it displays the same information twice. So basically, two tables are drawn by ASP and placed side by side.
Heres the code I'm using:
<asp:GridView ID="PackagesGV" runat="server" Width="520px">
<Columns>
<asp:BoundField DataField="ID" HeaderText="Package ID"/>
<asp:BoundField DataField="PackageName" HeaderText="Package Name"/>
<asp:BoundField DataField="PackageText" HeaderText="Package Text"/>
<asp:BoundField DataField="PackageImageID" HeaderText="Package Image"/>
<asp:BoundField DataField="PageID" HeaderText="Page ID"/>
</Columns>
</asp:GridView>
Also, the SQL Stored Procedure is pulling all of the fields required by the Gridview. The SQL is basically
"SELECT [ID], [PackageName], [PackageText], [PackageImageID], [PageID] FROM [Packages]"
So I'm not requesting the information twice using the Stored Procedure.
I've started ASP.NET in July, so I apologise now if this is something really simple.
Thanks!
Michael
You need to either set the GridView.AutoGenerateColumns Property to false or not set up the columns.
If you choose the former method your grid definition will become:
<asp:GridView ID="PackagesGV" runat="server" Width="520px" AutoGenerateColumns="False">
I have a asp.net detailsview control on a page. I've noticed that it always displays the raw text from my database field, it doesn't interpret the html in the text -- so it displays < b>mytext< /b> instead of just mytext in bold.
Is there anyway to get the control to interpret the html in the data being returned
Regards
melt
Can you post the code of your control? The basics are you need to set the HtmlEncode property to false. This is due to a difference in how labels and textboxes handle encoding, something meant to protect you from malicious scripts someone may have entered in these fields.
If you have it set to auto-generate fields (default), you'll need to change to BoundFields or TemplateFields instead and set the offending field's HtmlEncode Property to false.
You can see a code sample of the individual fields in MSDN, here's a simplified example:
<asp:DetailsView runat="server" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="ProductName" HeaderText="Product" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" />
<asp:BoundField DataField="HTMLField" HeaderText="HTML" HtmlEncode="false" />
</Fields>
</asp:DetailsView>