gridview

Showing date in MM/DD/YY format in a gridview column from .cs page/rowdatabound?

我们两清 提交于 2019-12-24 05:13:13
问题 I am getting a date time field from database with timestamp. My grid has an auto-generated column. I am formatting it in my .cs page dsWorkItems.Tables[0].Rows[count]["Date"] = !string.IsNullOrEmpty(dsWorkItems.Tables[0].Rows[count]["Date"].ToString()) ? ((DateTime)(dsWorkItems.Tables[0].Rows[count]["Date"])).ToShortDateString(): ""; In quick watch I am getting ((DateTime)(dsWorkItems.Tables[0].Rows[count]["Date"])).ToShortDateString() as 9/26/2013 but in grid I am getting 9/26/2013 12:00:00

Ordering the row_number using LinqToSql in asp.net/C#

寵の児 提交于 2019-12-24 05:12:21
问题 I have set of records in a database table lets call it Components Table which is defined as follows. The administrator can disable some of the components using disableflag which is the last column of the table. If a particular component is disabled it should not appear in the gridview of the user. I'm getting the data from the database and presenting through the gridview as shown here, if you observe the SNo values are not in order. The linq query that i'm using to retrieve the data is: var

ASP.NET Add column to Gridview

二次信任 提交于 2019-12-24 05:08:26
问题 I have a gridview that is displaying data from a database using LINQ to SQL. AssetDataContext db = new AssetDataContext(); equipmentGrid.DataSource = db.equipments.OrderBy(n => n.EQCN); I need to add a column at the end of the girdview that will have links to edit/delete/view the row. I need the link to be "http://localhost/edit.aspx?ID=" + idOfRowItem. 回答1: Try adding a TemplateField to your GridView like so: <Columns> <asp:TemplateField> <ItemTemplate> <a href="http://localhost/edit.aspx?ID

click gridview item and editext gets focus

和自甴很熟 提交于 2019-12-24 05:05:30
问题 I have displayed a gridview whose items are a textview and edittext.Now ,how to achieve function that I click the gridview item and the edittext get the focus? gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { how to override this function? I try that before: ((EditText)gridview.getChildAt(position).findViewById(R.id.grid_edittext)).requestFocus(); and also: ((ViewGroup)gridview.getChildAt

How to bind a GridView to a list of multiple types?

亡梦爱人 提交于 2019-12-24 04:57:12
问题 I get this error: System.Reflection.TargetException: Object does not match target type. when trying to bind a List<IEvent> where an IEvent can be an appointment, a birthday, or a few other calendar related event types. 回答1: ChanChan, GridView does not support binding to a collection of interfaces, Try redisigning your application to ensure binding only to a collection of concreate classes. The only workaround for this is to use base class (in your case Event) and bind to a collection of

GridView sorting doesn't work when I Enable Caching in Custome Paging and sorting

依然范特西╮ 提交于 2019-12-24 04:55:09
问题 I have a GridView that use a stored procedure for custom paging and sorting . It's OK and works fine (Both paging and sorting) , But the problem is when i Enable Caching in ObjectDataSource like : EnableCaching="True" It properly cache every page that the user visit , But at this case when the user want to sort it raise an error(While that works fine if EnableCaching ="False" : The data source 'ObjectDataSource1' does not support sorting with IEnumerable data. Automatic sorting is only

Get old value of label inside GridView during RowUpdating (ASP.NET GridView) C#

与世无争的帅哥 提交于 2019-12-24 04:24:10
问题 I've been struggling to find a way to get an "old" value of a label in my GridView. I've tried using hiddenFields to save them (this would give me this error) Error when using hiddenFields I've also tried using the EventArgs (e.OldValues) but those were always empty (So were the e.NewValues) Can anyone help me out? My GridView: <asp:GridView CssClass="gridview" ID="GridViewAdmin_Users" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging=

Yii2 : Gridview with fixed first column

夙愿已清 提交于 2019-12-24 04:24:04
问题 Can someone help me to implement a Gridview (Yii2) where the first column (NAME) was always visible and the others I could scroll horizontally to the side. My customers asked for an Excel-like interface where they could view and filter various customer information (various products marked YES or NO). At first, I have this example as a reference: REF 1 from bootsnip .scrolling table { table-layout: inherit; *margin-left: -100px; /*ie7*/ } .scrolling td, th { vertical-align: top; padding: 10px;

How to get row index according to clicked button from asp.net GridView?

喜欢而已 提交于 2019-12-24 04:02:26
问题 I have Gridview with some records (1 record=1 row). On every row I added a button to delete this record from my mysql db. Every row has the same button. The problem is I need to know in which row the button was clicked ? I need this to get a row index to get id of my record which is in that row. How can I do this in easiest way? Gridview: <asp:GridView ID="GridView1" runat="server" CellPadding="6" EnableModelValidation="True" ForeColor="#333333" GridLines="None" Caption="TWOJE WIZYTY" Font

Adding controls in gridview dynamically

余生颓废 提交于 2019-12-24 03:50:28
问题 I need to add controls to a GridView dynamically, so I added a PlaceHolder, but it it giving me an error. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { PlaceHolder plachldr = e.Row.FindControl("PlaceHolder2") as PlaceHolder; Button btn = new Button() { ID = "btnShhow", Text = "Show" }; plachldr.Controls.Add(btn); PlaceHolder placeholder = e.Row.FindControl("PlaceHolder1") as PlaceHolder; TextBox txt1 = new TextBox(); placeholder.Controls.Add(txt1); } While