HyperLinkField in Gridview not showing link on column's items - c#

I have a question today about the usage of HyperLinkField in a GridView. I have searched nearly everything, but nothing I try is working. I am running and ORACLE database and all of the fields below are string type EXCEPT for RECORD_DATE and RECORD_TIME. They are of type 'DATE'.
This is what I have:
<asp:HyperLinkField HeaderText="MODEL_NUMBER" DataTextField="MODEL_NUMBER" SortExpression="MODEL_NUMBER" DataNavigateUrlFields="MODEL_NUMBER, SERIAL_NUMBER, DEFECT_CODE, RECORD_DATE, RECORD_TIME"
DataNavigateUrlFormatString="~/AllAudits.aspx?Model={0}&Serial={1}&Defect={2}&RecordDate={3}&RecordTime={4}" />
Visual Studio has no complaints with the string, and the page loads fine and everything, but it isn't showing a link for the column labeled "MODEL_NUMBER" like it should be.
I tried:
NavigateUrl="~/AllAudits.aspx"
And that created a link, but I don't think I have the ability to pass parameters through this.
Can anyone point me in the correct direction on this?

It may have something to do with how you are passing in the date types. This thread seems to resolve the problem you are having.

Related

How to display DateTime as Date when Convert.ToDateTime() was run first

i'm stuck regarding a value I want to show. The problem is that I want to display in a GridView a Date value, but I can't parse it so it does that. I've tried to shrink the table column and several ways of parsing. Thank you so much for the help As it is now. And this is how it's parsed at the moment reserva.Fecha = Convert.ToDateTime(dr["fecha"].ToString());
DateTime object has both date and time associated with it. If you want to display only the date part of it, use the ToString() to only show the date with formatting defined. See Documentation here
DateTime.Parse(dr["fecha"].ToString()).ToString("MM-dd-yyyy");
You can also use the method ToShortDateString() to display only the Date part of the DateTime object.
DateTime.Parse(dr["fecha"].ToString()).ToShortDateString()
It turns out that the table I created previously was unable (I think) of displaying the data I had (in a List object) I still can´t display it from the list I want, but it shows the data I tell it to, so for now it works. Finally, instead of using <asp:TemplateField> <HeaderTemplate> <asp:Label for my table, I used <asp:BoundField>. I'm sorry if i'm not clear enough on the explanation, but I do believe it was a problem caused by using code I didn't understand so I don´t think it would happen to anyone else. Thank you so much everyone https://imgur.com/a/IWKHHvO

Selenium Find by Css help needed.-

Not a developer here.
I have two checkboxs with No IDs. I am find with selenium when I have an ID. But in this case the table was created with jquery datatables and no process is present to auto assign the IDs.
In css the line below would should give me the first row in that table.
#CompanyTableTable tr:first-of-type input[type="checkbox"].CompanySelector
This one selects the second entry.
#CompanyTable tr:nth-of-type(2) input[type="checkbox"].CompanySelector
I think I should be able to use this inside the following? But all my attempts return different formating errors.
driver.FindElement(By.CssSelector("**Css_Here**???")).Click();
Thanks in advance for any help.
Thanks everyone.
I had to add a wait and the below worked for grabbing the second checkbox
driver.FindElement (By.CssSelector("tr.even > td > input.CompanySelector")).Click();
I installed the Firefox IDE and ran the interface and grabbed the formatting from that.

Listview not showing first row per each page

I have a list view with which I am displaying a dataset. There is also a datapager.
The problem is, per each page, the first row of the dataset is not displayed in the list view.
So, the datapager displays text "showing element 1-10 of 22" but on the page, only 9 elements are displayed. The code is too big and complicated to paste here.
My question is, generally :
what can be the problem when the DataSet is right but after the binding, the listview shows 1 row less on each page.
I know my question is not specific enough, but I have to solve this problem and I need general ideas on where to look or how to debug, or what generally causes this kind of "first row not shown" problem.
Thanx
It's more than likely you're either not showing the first row, or the last row in the set. Check your conditions and comparisons.
Note that a DataSet is 0 based - the first row is .Rows[0], not .Rows[1]
The problem is solved. I dont know exactly what the problem was. This is a project developed by a team of programmers, and the bug was caused by something irrelevant to the context that I explained. Thank you all for the discussion.

C# Gridview cell returning empty string

Here's a picture of the gridview I'm working with: http://i.imgur.com/kFUTQ.png
Here's my issue:
I have a DropDownList (not shown in the picture) that has the same number of items as the Fraction DropDownList (shown in image). Each of the indices match with each other (ex: index 4 of the other field is the same as index 4 of the Fraction DropDownList), so when submitting the form, they have to have both of these match properly.
What I want to do is check and see if they do indeed match. I've tried:
this.gvRecords.Rows[0].Cells[2].Text
&
(((DropDownList)this.gvReserveRecords.Controls[0].Controls[0]
.FindControl("gvcbnFraction")).SelectedIndex
Neither have worked. They are just returning an empty string.
Here's some info that might help:
I am using ASP.NET Web Forms
The GridView is initially empty, but once the information is filled in, the 'Insert' LinkButton is clicked and the data is added to a database, and the GridView then calls DataBind().
I'm trying to compare the value of Fraction to a field outside of the GridView, if that matters at all.
Let me know if you need any other information!
You should be able to simply reference your DropDown control by its ID, in this case - gvcbnFraction. So, gvcbnFraction.SelectedIndex should give the integer index and gvcbnFraction.SelectedValue should give the string value.
If you aren't able to reference the drop down control in your code behind, then you are missing something that should be there. Possibly one of these:
Your designer.cs file doesn't include protected
global::System.Web.UI.WebControls.DropDownList gvcbnFraction;
Your .aspx file doesn't include CodeBehind="MySuperAwesomePage.aspx.cs"
Inherits="MyWebApp._Default" or something similar to that
Something else I just don't know about
If you are using Visual Studio, you can try dragging a control from the toolbox and see if you can reference it. Doing this will automatically update your designer.cs file, eliminating #1

Formatting columns inside of an ASP Repeater

I'm using an ASP repeater on my page, and I want it to create a 3 column grid. In my HTML page, I use a class which sets the third column so that it fits. Basically, the first 2 columns have a margin-right of 28px so it spaces them nicely and then the third class removes the margin-right so that the columns fit.
Problem is, when this comes into the repeater, I can't use the third class and I get a 2 column result. Any ideas on how I can overcome this?
Use a <table>. I know, I know, we aren't supposed to use tables anymore, right? If you are displaying tabular data, you should use a table. If it's a "grid", that sounds like tabular data to me. Is it?
I managed to resolve this without the use of a <table>. It turned out that the <form> didn't have enough width, so I amended this and it worked.

Categories

Resources