I have 2 WebServer Controls
<asp:TextBox ID="txtTextBox" runat="server"ClientIDMode="Static"MaxtLength="30"Width="35px"CssClass="labeltext"></asp:TextBox>
<asp:DropDownList ID ="ddlDropDown" runat ="server" CssClass="text">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="U">someValue1</asp:ListItem>
<asp:ListItem Value="Y">someValue2</asp:ListItem>
<asp:ListItem Value="N">someValue3</asp:ListItem>
</asp:DropDownList>
There are no Errors on my aspx Page. I have configured my datasets to read the 2 new columns ( I even double checked the designer file for the dsd and see both new columns). I have cleaned and rebuilt my solution but my code behind (.vb) only see the dropdown and not the Text Box,
So it turns out, somehow the dataset got out of sync. I think it was because I tried to copy and paste a property in my aspx. I undid all my changes and re applied them again with no issue.
Related
I've built the SqlFactory class to control my StoredProcedures, and I use it for all transactions between application and SQLServer. The part that I implemented last is file upload. But it won't do things as it should :( I've searched around the web not much could be found.
So basically I want to save my Report with name, description, and image.
Name and description are working perfectly, but for some reason it will not upload the file, it does not even reach the code for uploading it, which is:
If fuImage.PostedFile Is Nothing OrElse String.IsNullOrEmpty(fuImage.PostedFile.FileName) OrElse fuImage.PostedFile.InputStream Is Nothing Then
'nothing to upload
Else
Dim imagebytes(fuImage.PostedFile.InputStream.Length) As Byte
fuImage.PostedFile.InputStream.Read(imagebytes, 0, imagebytes.Length)
rep.FuImage = imagebytes
End If
rep.Name = txtName.Text
rep.Description = txtReportContent.Text
repFac.Save(rep)
The lines rep.FuImage = imagebytes and those below if statement are my factory lines it should be working but it's like fuImage FileUpload control never recognizes a file that's supposed to be selected.
This is my view part:
<asp:FileUpload ID="fuImage" runat="server" CssClass="fontChange" />
<asp:RegularExpressionValidator ID="rExpImage" runat="server" ControlToValidate="fuImage"
ErrorMessage="Only .gif, .jpg, .png, .tiff and .jpeg" ValidationExpression="(.*\.([Gg][Ii][Ff])|.*\.([Jj][Pp][Gg])|.*\.([Bb][Mm][Pp])|.*\.([pP][nN][gG])|.*\.([tT][iI][iI][fF])$)"
ValidationGroup="ReportValidationSummary" CssClass="failureNotification">*</asp:RegularExpressionValidator>
Note: I am aware that FileUpload does not work in asp:UpdatePanel, hence I'm using regular asp:Panel, I beginning to doubt if there are issues with all Panel controls... Also, I've looked around problems that mention a lot of things, and I'm quite lost.
Please help, and thank you.
EDIT:
I've also tried working around forms, nothing came out of it. My server side form is placed on my Master page, and that's the only one i use. I've tried placing form on each page, instead. Nothing changed. (Read this in someones question, thought I'd try too.)
Fixed. Problem was <ContentTemplate> was surrounding both <asp:UpdatePanel> and my EditPanel which was regular <asp:Panel>. That way it won't matter that FileUpload is not within update panel. It has to be set as a full post back with <Triggers>.
Code for Triggers:
<Triggers>
<asp:PostBackTrigger ControlID="Your_Control_ID" />
</Triggers>
I wrote a program using VB.NET. When I run the executable, it displays a DataGridView that may (or may not) have rows in it. The user can enter data, or hit an Update button to fetch data from a database. (The grid is NOT being used as a DataSource.)
The user can also set the font with another button: DataGridView1.font = "..."
If the grid DOES have rows in it, everything works as expected and the font is used in the grid.
If the grid does NOT have rows in it, the font does NOT change. Even after the user hits Update, or types in data.He has to entirely exit the program, and rerun it to see the font actually change.
Question:
How do I set the font on the grid, regardless of whether it:
Has rows.
Doesn't have rows.
Will have rows later.
I would think DataGridView1.font would ALWAYS change the font. No?
You can use the property EmptyGridview with a CssClass to change the way it displays this message.
For example:
Aspx
<asp:gridview id="EmptyGridview" runat="Server">
<EmptyDataRowStyle CssClass="gridview_vaciarow1"/>
</asp:gridview>
CSS
.gridview_vaciarow1{color:#ff0000, font-weight:bold;font-family:"Times New Roman",Georgia,Serif;}
Have a nice day!!
I have a vendor application which is precompiled. I want to add a template column into the aspx page, however I'm having some difficulty.
This works for me fine as "Available" is a column bound to the asp DataGrid:
<asp:TemplateColumn HeaderText="test">
<ItemTemplate>
<asp:Label ID="Label2" Text='<% #DataBinder.Eval(Container.DataItem, "Available") %>' runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
Now, I'm trying to basically create a template column, that takes the (int) "Available" column and divide it by 12 and then multiply by DateTime.Now.Date.Month.
I'm not having any luck with using DateTime within <% %> on this page.
Thanks,
Mark
You can remove inherits="Archive, App_Web_XXXXX" from <%# Page %> then bring your code into ASPX file and modify it.
I have a GridView in a page with paging enabled (sorting not enabled, not used). OnRowDataBound and OnPageIndexChanged events are assigned.
<asp:GridView ShowHeader="False" ID="GV1" runat="server" AutoGenerateColumns="False" OnRowDataBound="gridView_RowDataBound" DataSourceID="SqlDataSource1" GridLines="None" CellPadding="0" PageSize="25" AllowPaging="True" OnPageIndexChanging="GV1_PageIndexChanging">
Datasource is assigned just below gridview as:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:my_connectionstring %>"></asp:SqlDataSource>
OnRowDataBound is used to display content in a formatted way. I don't think it causes any problem:
Protected Sub gridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs).....
PageIndexChanging is defined as follows:
Protected Sub GV1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
GV1.PageIndex = e.NewPageIndex
GV1.DataBind()
End Sub
In Page_Load Part here's how I populate datasource. It's from custom query constructed in string tempSqlStr:
SqlDataSource1.SelectCommand = tempSqlStr
If Not Page.IsPostBack Then
GV1.DataBind()
End If
Everything seems to be working, I get results paged by 25 records, I can move through pages. But what I recognized is the content of pages are changing as I move between them. The amount of records do not change but I can see a record I saw on first page again in second, when I move back to first page and then again to second page content of second page changes and I see a different set of records.
I have printed tempSqlStr value to all pages, it is same on all pages (it is not in "not page.ispostback" part).
Can it be because I construct tempSqlStr in Page_Load section and GV1_PageIndex_Changing cannot see the value? If this is the case why following pages showing record?
Any comment is appreciated. Thank you.
The problem is most likely that you are not ordering the results returned and that is why. Execute your select statement 5 times and see if the results are the same and you will know if it is this. If it is then add an order by in your query. Let me know if this solved your problem otherwise we can look further...
I am assigning a 'ds' dataset to datagrid.In addition to that I want to add new column with check boxes.That new column will be first column of datagrid.
Currently I am using below code,
DataGrid1.DataSource = dsResult.Tables("Result")
Result table has 4 column....in addtion to that i want to column "Selection" with check boxes
You can add a checkbox inside the itemtemplate like
<ItemTemplate>
<asp:CheckBox ID="chkComplete" runat="server" />
</ItemTemplate>
For a basic understanding read this article
Including a CheckBox Control Inside an ASP.NET DataGrid...