Search Results

Search found 1260 results on 51 pages for 'gridview'.

Page 20/51 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Bind to a collection's view and just call ToString()

    - by womp
    I'm binding a GridView to a collection of objects that look like this: public class Transaction { public string PersonName { get; set; } public DateTime TransactionDate { get; set; } public MoneyCollection TransactedMoney { get; set;} } MoneyCollection simply inherits from ObservableCollection<T>, and is a collection of MyMoney type object. In my GridView, I just want to bind a column to the MoneyCollection's ToString() method. However, binding it directly to the TransactedMoney property makes every entry display the text "(Collection)", and the ToString() method is never called. I understand that it is binding to the collection's default view. So my question is - how can I make it bind to the collection in such a way that it calls the ToString() method on it? This is my first WPF project, so I know this might be a bit noobish, but pointers would be very welcome.

    Read the article

  • Passing a LINQ DataRow Reference in a GridView's ItemTemplate

    - by Bob Kaufman
    Given the following GridView: <asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false" DataKeyNames="UniqueID" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" > <Columns> <asp:BoundField HeaderText="Remarks" DataField="Remarks" /> <asp:TemplateField HeaderText="Listing"> <ItemTemplate> <%# ShowListingTitle( ( ( System.Data.DataRowView ) ( Container.DataItem ) ).Row ) %> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="Amount" DataField="Amount" DataFormatString="{0:C}" /> </Columns> </asp:GridView> which refers to the following code-behind method: protected String ShowListingTitle( DataRow row ) { Listing listing = ( Listing ) row; return NicelyFormattedString( listing.field1, listing.field2, ... ); } The cast from DataRow to Listing is failing (cannot convert from DataRow to Listing) I'm certain the problem lies in what I'm passing from within the ItemTemplate, which is simply not the right reference to the current record from the LINQ to SQL data set that I've created, which looks like this: private void PopulateGrid() { using ( MyDataContext context = new MyDataContext() ) { IQueryable < Listing > listings = from l in context.Listings where l.AccountID == myAccountID select l; GridView1.DataSource = listings; GridView1.DataBind(); } }

    Read the article

  • Sorting GridView Formed With Data Set

    - by nani
    Following Code is for Sorting GridView Formed With DataSet Source: http://www.highoncoding.com/Articles/176_Sorting_GridView_Manually_.aspx But it is not displaying any output. There is no problem in sql connection. I am unable to trace the error, please help me. Thank You. public partial class _Default : System.Web.UI.Page { private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; private DataSet GetData() { SqlConnection cnn = new SqlConnection("Server=localhost;Database=Northwind;Trusted_Connection=True;"); SqlDataAdapter da = new SqlDataAdapter("SELECT TOP 5 firstname,lastname,hiredate FROM EMPLOYEES", cnn); DataSet ds = new DataSet(); da.Fill(ds); return ds; } public SortDirection GridViewSortDirection { get { if (ViewState["sortDirection"] == null) ViewState["sortDirection"] = SortDirection.Ascending; return (SortDirection)ViewState["sortDirection"]; } set { ViewState["sortDirection"] = value; } } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; SortGridView(sortExpression, DESCENDING); } else { GridViewSortDirection = SortDirection.Ascending; SortGridView(sortExpression, ASCENDING); } } private void SortGridView(string sortExpression, string direction) { // You can cache the DataTable for improving performance DataTable dt = GetData().Tables[0]; DataView dv = new DataView(dt); dv.Sort = sortExpression + direction; GridView1.DataSource = dv; GridView1.DataBind(); } } aspx page asp:GridView ID="GridView1" runat="server" AllowSorting="True" OnSorting="GridView1_Sorting" /asp:GridView

    Read the article

  • Bind SQLiteDataReader to GridView in ASP.NET

    - by Charles Gargent
    Hi, this is all rather new to me, but I have searched for a good while and cant find any idea why I cant get this to work, dr looks like it is populated but I get this nullreferenceexeception when I try to bind to the gridview Thanks code SQLiteConnection cnn = new SQLiteConnection(@"Data Source=c:\log.db"); cnn.Open(); SQLiteCommand cmd = new SQLiteCommand(@"SELECT * FROM evtlog", cnn); SQLiteDataReader dr = cmd.ExecuteReader(); GridView1.DataSource = dr; GridView1.DataBind(); dr.Close(); cnn.Close(); Codebehind <asp:ContentPlaceHolder ID="MainContent" runat="server"> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </asp:ContentPlaceHolder> error Object reference not set to an instance of an object. at WPKG_Report.SiteMaster.Button1_Click(Object sender, EventArgs e) in C:\Projects\Report\Site.Master.cs:line 32 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Read the article

  • gridview column popup window

    - by peter
    i want to implement ajax hover menu and i have a grid gridview1 like this <asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand" runat="server" AutoGenerateColumns="False" Height="60px" Style="text-align: center" Width="869px" EnableViewState="False"> <Columns> <asp:BoundField HeaderText="Topic" DataField="Topic" /> <asp:BoundField DataField="Moderator" HeaderText="Moderator" /> <asp:BoundField DataField="Expert" HeaderText="Expert" /> <asp:BoundField DataField="StartTime" HeaderText="Start"> <HeaderStyle Width="175px" /> </asp:BoundField> <asp:BoundField DataField="EndTime" HeaderText="End"> <HeaderStyle Width="175px" /> </asp:BoundField> <asp:TemplateField HeaderText="Join" ShowHeader="False"> <ItemTemplate> <asp:Button ID="JoinBT" runat="server" CommandName="Join" Text="Join" Width="52px" /> </ItemTemplate> <HeaderStyle Height="15px" /> </asp:TemplateField> </Columns> </asp:GridView> so i registered <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> and added I added this way in code of gridview columns But i am getting fixed Edit/delete link in a new column rather than Hover menu,,Can any one tell me the solution to get hover menu

    Read the article

  • Concerned with footerrow in gridview

    - by ramyatk06
    hi guys, I have following gridview. <asp:GridView ID="gvMarks" runat="server" AutoGenerateColumns="false" DataKeyNames="MarkId" Width="80%" onrowdatabound="gvMarks_RowDataBound" ShowFooter="True" onrowcommand="gvMarks_RowCommand"> <Columns> <asp:TemplateField> <HeaderTemplate> SubjectCode </HeaderTemplate> <FooterTemplate> <asp:DropDownList ID="dlSubjectCode" runat="server" width="100px" AutoPostBack="false"></asp:DropDownList> </FooterTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Mark </HeaderTemplate> <FooterTemplate> <asp:TextBox ID="txtInternalMark" runat="server" ></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Insert </HeaderTemplate> <FooterTemplate> <asp:LinkButton ID="lnkInsert" runat="server" Text="Insert" CommandName="Insert" ></asp:LinkButton> </FooterTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="White" ForeColor="#000066" /> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> </asp:GridView> If i enter some value in txtInternalMark,iam not geting its value in code behind.Iam geting the value as "".Iam using following code if (e.CommandName.Equals("Insert")) { TextBox txtInternalMark = (TextBox)gvMarks.FooterRow.FindControl("txtInternalMark"); lblMessage.Text = txtInternalMark .Text; } Can anybody help to get the value of textbox in codebehind.

    Read the article

  • how to bind a list to a dropdown list in gridview

    - by user3721173
    I have a GridView that it contain a Drop-down list.I have a list that wanna to bind this list to drop-down in gridview. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="GridView1_RowDataBound"> <Columns> <ItemTemplate> <asp:Label ID="Label2" runat="server"></asp:Label> <asp:DropDownList ID="DropDownList3" runat="server" AppendDataBoundItems="True" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged1" > </asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> and protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { DropDownList dropdown = (DropDownList)e.Row.FindControl("DropDownList3"); ClassDal obj = new ClassDal(); List<phone> list = obj.GetAll(); dropdown.DataTextField = "phone"; dropdown.DataValueField = "id"; dropdown.DataSource = list.ToList(); dropdown.DataBind(); } and namespace sample_table { public class ClassDal { public List<phone> GetAll() { using (PracticeDBEntities1 context = new PracticeDBEntities1()) { return context.phone.ToList(); } } } } but i received this exception :Object reference not set to an instance of an object on the row: dropdown.DataTextField = "phone";

    Read the article

  • Including Data From DropDownList Into Gridview

    - by Mike Keller
    I feel a little embarassed posting two questions relating to the same problem, but the first one ended up answering a question that I believe is unrelated to the solution so I'm leaving it up and outlining what I'm trying to accomplish with the hopes that someone can help out a .Net noob. What I need to be able to do is create a field in my gridview that contains a link that passes two variables. One is pulled from within the gridviews datasource and the other needs to be pulled from a textbox control outside the gridview. From what I've read so far you cannot use a hyperlinkfield for this as the datanavigateurlfields cannot be set to pull from anything but the gridview's data source. What I attempted to do was create a template field where in the itemtemplate I called: <a href="example.aspx?e=<%# Eval(ExampleList.SelectedItem.Value) %>">Test</a> That comes back with an error like this: DataBinding: 'System.Data.DataRowView' does not contain a property with the value 'TestData' Any clues to make this happen would be appreciated, like I said I'm pretty new to .Net so please be gentle. I tried to do my homework before posting this.

    Read the article

  • right click values for Gridview column

    - by peter
    I have grid named 'GridView1' and displaying columns like this <asp:GridView ID="GridView1" OnRowCommand="ScheduleGridView_RowCommand" runat="server" AutoGenerateColumns="False" Height="60px" Style="text-align: center" Width="869px" EnableViewState="False"> <Columns> <asp:BoundField HeaderText="Topic" DataField="Topic" /> <asp:BoundField DataField="Moderator" HeaderText="Moderator" /> <asp:BoundField DataField="Expert" HeaderText="Expert" /> <asp:BoundField DataField="StartTime" HeaderText="Start" > <HeaderStyle Width="175px" /> </asp:BoundField> <asp:BoundField DataField="EndTime" HeaderText="End" > <HeaderStyle Width="175px" /> </asp:BoundField> <asp:TemplateField HeaderText="Join" ShowHeader="False"> <ItemTemplate> <asp:Button ID="JoinBT" runat="server" CommandArgument="<%# Container.DataItemIndex %>" CommandName="Join" Text="Join" Width="52px" /> </ItemTemplate> <HeaderStyle Height="15px" /> </asp:TemplateField> </Columns> </asp:GridView> Here what is my requirement is whenever we right click on each row in gridview ,it should display three option join meeting(if we click it will go to meeting.aspx),,view details(will go to detail.aspx),,Subscribe(subscribe.aspx) just like when we click right any where we can see view,sortby,refresh like that..Do we need to implement javascript here

    Read the article

  • asp.net grid view hyper link pass values to new window

    - by srihari
    hai guys here is my question please help me I have a gridview with hyperlink fields here my requirement is if I click on hyperlink of particular row I need to display that particular row values into other page in that page user will edit record values after that if he clicks on update button I need to update that record values and get back to previous home page. if iam clicking hyper link in first window new window should open with out any url tool bar and minimize close buttons like popup modular Ajax ModalPopUpExtender but iam un able to ge that that one please help me the fillowing code is defalut.aspx <head runat="server"> <title>PassGridviewRow values </title> <style type="text/css"> #gvrecords tr.rowHover:hover { background-color:Yellow; font-family:Arial; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView runat="server" ID="gvrecords" AutoGenerateColumns="false" HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White" DataKeyNames="UserId" RowStyle-CssClass="rowHover"> <Columns> <asp:TemplateField HeaderText="Change Password" > <ItemTemplate> <a href ='<%#"UpdateGridviewvalues.aspx?UserId="+DataBinder.Eval(Container.DataItem,"UserId") %>'> <%#Eval("UserName") %> </a> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="FirstName" HeaderText="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" /> <asp:BoundField DataField="Email" HeaderText="Email" /> </Columns> </asp:GridView> </div> </form> </body> </html> following code default.aspx.cs code using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGridview(); } } protected void BindGridview() { SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=SSPI;Initial Catalog=testdb1"); con.Open(); SqlCommand cmd = new SqlCommand("select * from UserDetails", con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); con.Close(); DataSet ds = new DataSet(); da.Fill(ds); gvrecords.DataSource = ds; gvrecords.DataBind(); } } this is updategridviewvalues.aspx <head runat="server"> <title>Update Gridview Row Values</title> <script type="text/javascript"> function Showalert(username) { alert(username + ' details updated successfully.'); if (alert) { window.location = 'Default.aspx'; } } </script> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td colspan="2" align="center"> <b> Edit User Details</b> </td> </tr> <tr> <td> User Name: </td> <td> <asp:Label ID="lblUsername" runat="server"/> </td> </tr> <tr> <td> First Name: </td> <td> <asp:TextBox ID="txtfname" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Last Name: </td> <td> <asp:TextBox ID="txtlname" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Email: </td> <td> <asp:TextBox ID="txtemail" runat="server"></asp:TextBox> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnUpdate" runat="server" Text="Update" onclick="btnUpdate_Click" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" onclick="btnCancel_Click"/> </td> </tr> </table> </div> </form> </body> </html> and my updategridviewvalues.aspx.cs code is follows using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class UpdateGridviewvalues : System.Web.UI.Page { SqlConnection con = new SqlConnection("Data Source=.;Integrated Security=SSPI;Initial Catalog=testdb1"); private int userid=0; protected void Page_Load(object sender, EventArgs e) { userid = Convert.ToInt32(Request.QueryString["UserId"].ToString()); if(!IsPostBack) { BindControlvalues(); } } private void BindControlvalues() { con.Open(); SqlCommand cmd = new SqlCommand("select * from UserDetails where UserId=" + userid, con); SqlDataAdapter da = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); con.Close(); DataSet ds = new DataSet(); da.Fill(ds); lblUsername.Text = ds.Tables[0].Rows[0][1].ToString(); txtfname.Text = ds.Tables[0].Rows[0][2].ToString(); txtlname.Text = ds.Tables[0].Rows[0][3].ToString(); txtemail.Text = ds.Tables[0].Rows[0][4].ToString(); } protected void btnUpdate_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd = new SqlCommand("update UserDetails set FirstName='" + txtfname.Text + "',LastName='" + txtlname.Text + "',Email='" + txtemail.Text + "' where UserId=" + userid, con); SqlDataAdapter da = new SqlDataAdapter(cmd); int result= cmd.ExecuteNonQuery(); con.Close(); if(result==1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Showalert('"+lblUsername.Text+"')", true); } } protected void btnCancel_Click(object sender, EventArgs e) { Response.Redirect("~/Default.aspx"); } } My requirement is new window should come like pop window as new window with out having url and close button my database tables is ColumnName DataType ------------------------------------------- UserId Int(set identity property=true) UserName varchar(50) FirstName varchar(50) LastName varchar(50) Email Varchar(50)

    Read the article

  • constructing paramater query SQL - LIKE % in .cs and in grid view

    - by Indranil Mutsuddy
    Hello friends, I am trying to implement admin login and operators(india,australia,america) login, now operator id starts with 'IND123' 'AUS123' and 'AM123' when operator india logs in he can see the details of only members have id 'IND%', the same applies for an australian and american users and when admin logs in he can see details of members with id 'IND%' or 'AUS%' or 'AM%' i have a table which defines the role i.e admin or operator and their prefix(IND,AUS respectively) In loginpage i created a session for Role and prefix PREFIX = myReader["Prefix"].ToString(); Session["LoginRole"] = myReader["Role"].ToString(); Session["LoginPrefix"] = String.Concat(PREFIX + "%"); works fine In main page(after login) i have to count the number of member so i wrote string prefix = Session["LoginPrefix"].ToString(); string role = Session["LoginRole"].ToString(); if (role.Equals("ADMIN")) StrMemberId = "select count(*) from MemberList"; else StrMemberId = "select count(*) from MemberList where MemberID like '"+prefix+"'"; thatworks fine too Problem: 1. i want to constructor parameter something like StrMemberId = "select count(*) from MemberList where MemberID like '@prefix+'"; myCommd.Parameters.AddWithValue("@prefix", prefix); Which is not working 2 Displaying the members in gridview i need to give condition (something like if (role.Equals("ADMIN")) show all members else show member depending on the operator prefix)the list of members in operator mode and admin mode. - where to put the condition in gridview how to apply these please suggest something Regards Indranil

    Read the article

  • How do I scrape information off ASP.NET websites when paging and JavaScript links are being used?

    - by Ian Roke
    I have been given a staff list which is supposed to be up to date but it doesn't match an intranet People Finder which is written in ASP.NET. As the information is sensitive I am not able to access the database the People Finder is using so the only way I can get at the information is by scraping the structure starting at the top brass at the top and then going through each tier in turn. Each person has a Staff number which then forms the URL http://intranet/peoplefinder/index.aspx?srn=ABC1234 and then all the people who report to them are listed underneth in the format <a id="gvEmployees_ctl03_lnkFullName" href="index.aspx?srn=ABC4321" target="_self"> where each URL indicates the Staff number and provides a link to their team. The trouble arises when the teams are big as paging is implemented in the GridView with an URL such as <a href="javascript:__doPostBack('gvEmployees','Page$2')">2</a>. How would I scrape this page, capture the SRN and other details along with the people who report to the person on all pages of the GridView then loop through each reportee and do the same process until the whole list is complete?

    Read the article

  • Populate textboxes with XmlNode.Attributes

    - by Doug
    I have Data.xml: <?xml version="1.0" encoding="utf-8" ?> <data> <album> <slide title="Autum Leaves" description="Leaves from the fall of 1986" source="images/Autumn Leaves.jpg" thumbnail="images/Autumn Leaves_thumb.jpg" /> <slide title="Creek" description="Creek in Alaska" source="images/Creek.jpg" thumbnail="images/Creek_thumb.jpg" /> </album> </data> I'd like to be able to edit the attributes of each Slide node via GridView (that has a "Select" column added.) And so far I have: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = GridView1.SelectedIndex; LoadXmlData(selectedIndex); } private void LoadXmlData(int selectedIndex) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(MapPath(@"..\photo_gallery\Data.xml")); XmlNodeList nodelist = xmldoc.DocumentElement.ChildNodes; XmlNode xmlnode = nodelist.Item(selectedIndex); titleTextBox.Text = xmlnode.Attributes["title"].InnerText; descriptionTextBox.Text = xmlnode.Attributes["description"].InnerText; sourceTextBox.Text = xmlnode.Attributes["source"].InnerText; thumbTextBox.Text = xmlnode.Attributes["thumbnail"].InnerText; } The code for LoadXmlData is just a guess on my part - I'm new to working with xml in this way. I'd like have the user to slected the row from the gridview, then populate a set of text boxes with each slide attributed for updating back to the Data.xml file. The error I'm getting is Object reference not set to an instance of an object" at the line: titleTextBox.Text = xmlnode.Attributes["@title"].InnerText; so I'm not reaching the attribute "title" of the slide node. Thanks for any ideas you may have.

    Read the article

  • populate textboxs with xml node attributes

    - by Doug
    I have Data.xml: <?xml version="1.0" encoding="utf-8" ?> <data> <album> <slide title="Autum Leaves" description="Leaves from the fall of 1986" source="images/Autumn Leaves.jpg" thumbnail="images/Autumn Leaves_thumb.jpg" /> <slide title="Creek" description="Creek in Alaska" source="images/Creek.jpg" thumbnail="images/Creek_thumb.jpg" /> </album> </data> I'd like to be able to edit the attributes of each Slide node via GridView (that has a "Select" column added.) And so far I have: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = GridView1.SelectedIndex; LoadXmlData(selectedIndex); } private void LoadXmlData(int selectedIndex) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(MapPath(@"..\photo_gallery\Data.xml")); XmlNodeList nodelist = xmldoc.DocumentElement.ChildNodes; XmlNode xmlnode = nodelist.Item(selectedIndex); titleTextBox.Text = xmlnode.Attributes["title"].InnerText; descriptionTextBox.Text = xmlnode.Attributes["description"].InnerText; sourceTextBox.Text = xmlnode.Attributes["source"].InnerText; thumbTextBox.Text = xmlnode.Attributes["thumbnail"].InnerText; The code for LoadXmlData is just a guess on my part - I'm new to working with xml in this way. I'd like have the user to slected the row from the gridview, then populate a set of text boxes with each slide attributed for updating back to the Data.xml file. The error I'm getting is "Object reference not set to an instance of an object" at the line: titleTextBox.Text = xmlnode.Attributes["@title"].InnerText; - so I'm not reaching the attribute "title" of the slide node. Thanks for any ideas you may have.

    Read the article

  • Web Grid, Client side Binding VS. Server side HTML generation

    - by Ron Harlev
    I'm working on replacing an existing web grid in an ASP.NET web application, with a new implementation. The existing grid is powerful, but not flexible enough. It also brings with it all kind of frameworks we don't like to have on our web pages. While looking into existing options I noticed I can break the available solutions into two main approaches. The older approach is represented best by the ASP.NET GridView. This is a classic ASP.NET control that generates the needed HTML on the server, based on a given set of data. The newer approach is depending on client side rendering, mainly with jQuery. A good example would be jqGrid. Only the data is sent to the client (Usually with JSON or XML) In the GridView case, if I want an AJAX behavior, I would have to implement it with something like an update panel. Is there a definitive choice I should make? Is there a good chance of achieving the same snappy behavior I get with jqGrid (even with many records), with server side rendered controls? Is there some hybrid implementation incorporating both approaches?

    Read the article

  • Will this class cause memory leaks, and does it need a dispose method? (asp.net vb)

    - by Phil
    Here is the class to export a gridview to an excel sheet: Imports System Imports System.Data Imports System.Configuration Imports System.IO Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Namespace ExcelExport Public NotInheritable Class GVExportUtil Private Sub New() End Sub Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView) HttpContext.Current.Response.Clear() HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName)) HttpContext.Current.Response.ContentType = "application/ms-excel" Dim sw As StringWriter = New StringWriter Dim htw As HtmlTextWriter = New HtmlTextWriter(sw) Dim table As Table = New Table table.GridLines = GridLines.Vertical If (Not (gv.HeaderRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.HeaderRow) table.Rows.Add(gv.HeaderRow) End If For Each row As GridViewRow In gv.Rows GVExportUtil.PrepareControlForExport(row) table.Rows.Add(row) Next If (Not (gv.FooterRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.FooterRow) table.Rows.Add(gv.FooterRow) End If table.RenderControl(htw) HttpContext.Current.Response.Write(sw.ToString) HttpContext.Current.Response.End() End Sub Private Shared Sub PrepareControlForExport(ByVal control As Control) Dim i As Integer = 0 Do While (i < control.Controls.Count) Dim current As Control = control.Controls(i) If (TypeOf current Is LinkButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, LinkButton).Text)) ElseIf (TypeOf current Is ImageButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, ImageButton).AlternateText)) ElseIf (TypeOf current Is HyperLink) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, HyperLink).Text)) ElseIf (TypeOf current Is DropDownList) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, DropDownList).SelectedItem.Text)) ElseIf (TypeOf current Is CheckBox) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, CheckBox).Checked)) End If If current.HasControls Then GVExportUtil.PrepareControlForExport(current) End If i = (i + 1) Loop End Sub End Class End Namespace Will this class cause memory leaks? And does anything here need to be disposed of? The code is working but I am getting frequent crashes of the app pool when it is in use. Thanks.

    Read the article

  • ASP.NET SqlDataSource update and create FK reference

    - by William
    The short version: I have a grid view bound to a data source which has a SelectCommand with a left join in it because the FK can be null. On Update I want to create a record in the FK table if the FK is null and then update the parent table with the new records ID. Is this possible to do with just SqlDataSources? The detailed version: I have two tables: Company and Address. The column Company.AddressId can be null. On my ascx page I am using a SqlDataSource to select a left join of company and address and a GridView to display the results. By having my UpdateCommand and DeleteCommand of the SqlDataSource execute two statements separated by a semi-colon I am able to use the GridView's Edit and Delete functionality to update both table simultaneously. The problem I have is when the Company.AddressId is null. What I need to have happen is have the data source create a record in the Address table and then update the Company table with the new Address.ID then proceed with the update as usual. I would like to do this with just data sources if possible for consistency/simplicity sake. Is it possible to have my data source do this, or perhaps add a second data source to the page to handle some of this? Once I have that working I can probably figure out how to make it work with the InsertCommand as well but if you are on a roll and have an answer for how to make that fly as well feel free to provide it. Thanks.

    Read the article

  • Will this class cause memory leaks, and does anything need disposing of? (asp.net vb)

    - by Phil
    Here is the class to export a gridview to an excel sheet: Imports System Imports System.Data Imports System.Configuration Imports System.IO Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Namespace ExcelExport Public NotInheritable Class GVExportUtil Private Sub New() End Sub Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView) HttpContext.Current.Response.Clear() HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName)) HttpContext.Current.Response.ContentType = "application/ms-excel" Dim sw As StringWriter = New StringWriter Dim htw As HtmlTextWriter = New HtmlTextWriter(sw) Dim table As Table = New Table table.GridLines = GridLines.Vertical If (Not (gv.HeaderRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.HeaderRow) table.Rows.Add(gv.HeaderRow) End If For Each row As GridViewRow In gv.Rows GVExportUtil.PrepareControlForExport(row) table.Rows.Add(row) Next If (Not (gv.FooterRow) Is Nothing) Then GVExportUtil.PrepareControlForExport(gv.FooterRow) table.Rows.Add(gv.FooterRow) End If table.RenderControl(htw) HttpContext.Current.Response.Write(sw.ToString) HttpContext.Current.Response.End() End Sub Private Shared Sub PrepareControlForExport(ByVal control As Control) Dim i As Integer = 0 Do While (i < control.Controls.Count) Dim current As Control = control.Controls(i) If (TypeOf current Is LinkButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, LinkButton).Text)) ElseIf (TypeOf current Is ImageButton) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, ImageButton).AlternateText)) ElseIf (TypeOf current Is HyperLink) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, HyperLink).Text)) ElseIf (TypeOf current Is DropDownList) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, DropDownList).SelectedItem.Text)) ElseIf (TypeOf current Is CheckBox) Then control.Controls.Remove(current) control.Controls.AddAt(i, New LiteralControl(CType(current, CheckBox).Checked)) End If If current.HasControls Then GVExportUtil.PrepareControlForExport(current) End If i = (i + 1) Loop End Sub End Class End Namespace Will this class cause memory leaks? And does anything here need to be disposed of? The code is working but I am getting the app pool falling over frequently when it is in use. Thanks.

    Read the article

  • Bind to a collection's view and just call ToString() in WPF

    - by womp
    I'm binding a GridView to a collection of objects that look like this: public class Transaction { public string PersonName { get; set; } public DateTime TransactionDate { get; set; } public MoneyCollection TransactedMoney { get; set;} } MoneyCollection simply inherits from ObservableCollection<T>, and is a collection of MyMoney type object. In my GridView, I just want to bind a column to the MoneyCollection's ToString() method. However, binding it directly to the TransactedMoney property makes every entry display the text "(Collection)", and the ToString() method is never called. Note that I do not want to bind to the items in MoneyCollection, I want to bind directly to the property itself and just call ToString() on it. I understand that it is binding to the collection's default view. So my question is - how can I make it bind to the collection in such a way that it calls the ToString() method on it? This is my first WPF project, so I know this might be a bit noobish, but pointers would be very welcome.

    Read the article

  • android populating gridivew from a url string

    - by user1685991
    I am building an android application in which i am trying to read data from a url and want to display the data in a gridview. But i have some problem or dont understand to how to display the array list on grdiview. Here is my code for reading data from php url ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); //http post try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://sml.com.pk/a/smldb.php"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); }catch(Exception e){ Log.e("log_tag", "Error in http connection"+e.toString()); } //convert response to string try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); sb = new StringBuilder(); sb.append(reader.readLine() + "\n"); String line="0"; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result=sb.toString(); }catch(Exception e){ Log.e("log_tag", "Error converting result "+e.toString()); } //paring data double des; double value; try{ jArray = new JSONArray(result); JSONObject json_data=null; for(int i=0;i<jArray.length();i++){ json_data = jArray.getJSONObject(i); LAT=json_data.getDouble("TITLE"); LANG=json_data.getDouble("A"); } } catch(JSONException e1){ Toast.makeText(getBaseContext(), "No Vehicles Found" ,Toast.LENGTH_LONG).show(); } catch (ParseException e1) { e1.printStackTrace(); } Here TITLE and A are my two columns of DB Table and i want to display them on gridview please any one help me to do this according to my current code. Here is my live url for data string http://sml.com.pk/a/smldb.php

    Read the article

  • ObjectDataSource firing twice, or on its own

    - by LoveMeSomeCode
    Can someone explain exactly how/when an ObjectDataSource fires? I have an ASP.NET page, with a GridView, which is referencing an ODS. I put a breakpoint in the method the ODS is using, and noticed it was firing twice. I looked into the code and the answer seemed obvious at first. I had Page_Load() { if(!Page.IsPostBack) { MethodA(); MethodB(); } } where MethodA and MethodB were both eventually calling gv.DataBind(). This made sense because I assume that each call to GridView.DataBind() would result in asking the ODS for data, and therefore running my data access method. The weird thing is that when comment out the call to MethodA, it still fires twice. Checking the call stack shows the method being run first as a result of MethodB, and then again, with no trail except [External Code]. This mystery load does not happen when I let MethodA and MethodB both execute. Any idea what's going on here? Any idea what other code I might have that is asking the ODS for data? I'm starting to think all these 'no code' data controls are more obfuscation and BS than they're worth.

    Read the article

  • WPF Check/Uncheck all checkboxes located in a gridview

    - by toni
    Hi! I have a gridview with some columns. One of these columns is checkbox type. Then I have two buttons in my UI, one for check all and another for uncheck all. I would like to check all checkboxes in the column when I press the a button and uncheck all checkboxes when I press the another one. How can I do this? Some snippet code: <... <Classes:SortableListView x:Name="lstViewRutas" ItemsSource="{Binding Source={StaticResource RutasCollectionData}}" ... > <...> <GridViewColumn Header="Activa" Width="50"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox x:Name="chkBxF" Click="chkBx_Click" IsChecked="{Binding Path=Activa}" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <...> </Classes:SortableListView> <...> </Page> My data object binding to gridview is: namespace GParts.Classes { public class RutasCollection { /// <summary> /// Colección de datos de la tabla /// </summary> ObservableCollection<RutasData> _RutasCollection; /// <summary> /// Constructor. Crea una nueva instancia tipo ObservableCollection /// de tipo RutasData /// </summary> public RutasCollection() { _RutasCollection = new ObservableCollection<RutasData>(); } /// <summary> /// Retorna el conjunto entero de rutas en la colección /// </summary> public ObservableCollection<RutasData> Get { get { return _RutasCollection; } } /// <summary> /// Retorna el conjunto entero de rutas en la colección /// </summary> /// <returns></returns> public ObservableCollection<RutasData> GetCollection() { return _RutasCollection; } /// <summary> /// Añade un elemento tipo RutasData a la colección /// </summary> /// <param name="hora"></param> public void Add(RutasData ruta) { _RutasCollection.Add(ruta); } /// <summary> /// Elimina un elemento tipo RutasData de la colección /// </summary> /// <param name="ruta"></param> public void Remove(RutasData ruta) { _RutasCollection.Remove(ruta); } /// <summary> /// Elimina todos los registros de la colección /// </summary> public void RemoveAll() { _RutasCollection.Clear(); } /// <summary> /// Inserta un elemento tipo RutasData a la colección /// en la posición rowId establecida /// </summary> /// <param name="rowId"></param> /// <param name="ruta"></param> public void Insert(int rowId, RutasData ruta) { _RutasCollection.Insert(rowId, ruta); } } /// <summary> /// Clase RutasData /// </summary> // Registro tabla interficie pantalla public class RutasData { public int Id { get; set; } public bool Activa { get; set; } public string Ruta { get; set; } } } and in my page loaded event I do this to populate gridview: // Obtiene datos tabla Rutas var tbl_Rutas = Accessor.GetRutasTable(); // This method returns entire table foreach (var ruta in tbl_Rutas) { _RutasCollection.Add(new RutasData { Id = (int) ruta.Id, Ruta = ruta.Ruta, Activa = (bool) ruta.Activa }); } // Enlaza los datos con el objeto proveedor RutasCollection lstViewRutas.ItemsSource = _RutasCollection.GetCollection(); Everything is ok but now I would like to check/uncheck all checkboxes in the gridviewcolumn when I press one button or another. How can I do this? Something like this¿? I receive an error that says I can modify itemsource property. private void btnCheckAll_Click(object sender, RoutedEventArgs e) { // Update data object bind to gridview ObservableCollection<RutasData> listas = _RutasCollection.GetCollection(); foreach (var lst in listas) { ((RutasData)lst).Activa = true; } // Update with new values the UI lstViewRutas.ItemsSource = _RutasCollection.GetCollection(); } Thanks!

    Read the article

  • ASP.NET VB.NET GridView adding anchor tag to a cell

    - by user3036965
    I have an GridView control with some data in the first cell throughout the column. Ineed to make that cell data into a hyperlink (anchor tag) like the following. <a href=""myPage.aspx?r=" & strParam & """>" & strData & "</a>" Can anyone advise on the most effective way to do this? I am using a datatable and then assigning the datatable to the gridview. Any advice would be greatly appreciated. I need to use the Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs). So I could add a hyperlink whatabout getting the parameters into the RowDataBound event is where my skills are falling down. Thank you

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >