|
I am facing a peculiar problem in Gridview. Details I mentioned here.
I found out that the issue is because if I set the below code in RowDataBound event.
e.Row.Cells[0].Visible = false;
When I commented this, paging is coming properly. Now the issue is that, first column is visible which is an ID column, which shouldn't show to the user. I couldn't understand how this will affect the paging of Gridview.
Anybody please suggest any way to hide the column without affecting the paging?
Thanks
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
What if you create a way of storing the value inside each row without it having a column dedicated to it ? What if it's not column 0 you hide, might it work OK then ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That will work. But how will I store the Id value without a column in a row? The datatable returns 5 columns out of which 1 is Id column.
Is it possible to store the value inside each row without a dedicated column?
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Instead of using standard columns, write your own column definitions. You could then have a control in one column that renders the data you want to see, and has an id which contains the id of the row. That sort of thing.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Exactly!!
That's what I done now and it's working. I made column defintions and then made the first column as DataKey column (for another purpose). The column also made as visible = false. The paging also working properly.
Thanks a lot Christian.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Hi,
I was wondering if retrieving the input in MVC is always string based?
Like requesting.form a "select multiple" (aka listbox)..
Is any other method than retrieving the values in a comma-separated string? Like "043,015,091"
Or for example a checkbox.. is it possible to retrieve a bool instead of parsing a string?
Because everything must be retrieved by using Request.Form
Please notice that i'm talking about ASP.NET MVC: That means i'm retrieving the values from a controller (POST) and not in the SomeButton_Click or something. In a NOT MVC way it would be all object oriented by using asp controls and etc.
|
|
|
|
|
Sounds like MVC sucks.
A website posts everything as a string. So, a string is all you will ever get. That's how the web works, it has nothing to do with MVC or ASP.NET.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
But with checkboxes, for example, when you use ASP.NET (not mvc) you can manage them as if their were winforms checkboxes (ie. myCheckBox.Value is bool),
And with Listboxes, you can refer to the ith item in the list (because its an array), and so on..
|
|
|
|
|
Because ASP.NET converts it all for you. Which is why I said, it sounds like MVC sucks.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Because ASP.NET converts it all for you. Which is why I said, it sounds like MVC sucks.
Seriously. MVC is like a step backwards. I haven't had any problems with ASP.Net, I don't understand what issues MVC fixed. Really, I don't get it even a little bit.
I didn't get any requirements for the signature
|
|
|
|
|
MVC solves the separation of concerns.. thats what it "fixes"
|
|
|
|
|
Christian Graus wrote: Which is why I said, it sounds like MVC sucks.
A broad statement that can fit any number of situations, tools, technologies, etc.
sounds like [insert name here] sucks.
only two letters away from being an asset
|
|
|
|
|
Well, I only have his description to go on, so that is what I was commenting on.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Sounds like MVC sucks.
Not in all aspects.
It is good if you want better testability, reduced payload, meaningful URLs and many other things. Two things which I don't like about ASP.NET MVC are, writing markup and server side code together like we did in old ASP and installations on IIS6. Installation on any IIS versions prior to 7 is not very straightforward.
|
|
|
|
|
Hi
I am building an asp.net web application using visual studio 2008 with .NET 3.5 on Windows XP 32 bit machine where I have the server as well. C# and javascript are used.
There is contactUs.aspx, once the form is submitted successfully, I want to run the jQuery in the contactUs.js file starting from line 20 (var dataString = 'name=' + name + '&email=' + email;) to line 40 (return false;).
How do I wire it up.
contactUs.aspx.cs
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class contactUs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
totalCareAutoTableAdapters.ContactUsTableAdapter ContactUsAdapter = new totalCareAutoTableAdapters.ContactUsTableAdapter();
int new_ContactUs = Convert.ToInt32(ContactUsAdapter.InsertContactUs(name.Text, mobileNumber.Text, emailAddr.Text, subjectTitle.Text, messege.Text));
}
catch (Exception ex)
{
}
}
}
</pre>
contactUs.js
<pre>
/// <reference path="jquery-1.3.2-vsdoc2.js" />
$(function()
{
$('.error').hide();
$(".button").click(function()
{
// validate and process form here
$('.error').hide();
var name = $("[id$='name']").val();
var email = $("[id$='emailAddr']").val();
if (name == "")
{
$("[id$='name_error']").show();
$("[id$='name']").focus();
return false;
}
var dataString = 'name=' + name + '&email=' + email;
$.ajax({
type: "POST",
url: "siteMap.aspx",
data: dataString,
success: function()
{
$("[id$='contact_form']").html("<div id='message'></div>");
$("[id$='message']").html("<h2>Contact Form Submitted!</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function()
{
$("[id$='message']").append("<img id='checkmark' src='images/fiat.jpeg' />");
});
}
});
return false;
});
});
</pre>
|
|
|
|
|
Well, once postback has occured, your page will be rerendered, and the javascript will be able to run. If you need to run a specific method after a specific postback, inject a method call into the page so it runs when rendered.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
To begin with I AM NOT AN ASP.NET Coder. So please bear with me and my questions.
I have to build this in asp instead of silverlight so it can be accessed on blackberries.
I have a page that collects a ton of data about where a link will be started.
The engineers then construct 4-8 links to the endpoint terminus.
What I'm trying to do is have each link get added to the list of links until they click the done button.
Each 'link' in the list would be as follows:
lable'Leg ' lable'nn' text' ' button[next link] button[done]
the lable with the 'nn' value is populated by me and is 1, 2, 3, 4, etc.
the button with [next link] would trigger adding the next set of lables, textbox, and buttons.
the button with [done] would populate the database with all of the links.
In a prior post I was given invalid control types to use and the person never answered me after that.
So how would I do this in ASP.Net so that the input is always sent back to me and the next link is added to the list with each postback?
|
|
|
|
|
A few ways you could do it.
Use a repeater control with a template that contains the label the textbox controls
Pseudo code here
<repeater>
<template>
<label>
<textbox>
</template>
</repeater>
<button value=Next><button value=Done>
Bind the repeater to some collection. Handle the click event for the button and add an item to the collection, then rebind to the repeater.
Another way is to handle the click event for the button and add the next set of controls to the controls collection of the page.
only two letters away from being an asset
|
|
|
|
|
Mark,
Thank you so much. I have everything almost working.
After a little debugging I found I had to code a bit to rebuild the collection of values for each new connection added.
Now I have just a tiny issue I cannot figure out. My logic is quite simple:
protected void NextLegEventHandler( object sender, EventArgs e )
{
LegItem legItem = new LegItem( );
legNames = new Dictionary<int, LegItem>( );
foreach ( Control item in LegConstructor.Controls )
{
if ( !( item is RepeaterItem ) ) continue;
if ( item.Controls.Count <= 1 ) continue;
foreach ( Control textItem in item.Controls )
{
TextBox currentControl = textItem as TextBox;
if ( currentControl == null ) continue;
int result = 0;
if ( Int32.TryParse( currentControl.Text, out result ) )
{
legItem = new LegItem( );
legItem.LegNumber = result;
}
else
{
legItem.PortName = currentControl.Text;
legNames.Add( legItem.LegNumber, legItem );
}
}
}
LegItem newLeg = new LegItem( );
newLeg.LegNumber = legNames.Count + 1;
newLeg.PortName = string.Empty;
legNames.Add( newLeg.LegNumber, newLeg );
this.LegConstructor.DataSource = legNames.Values.ToArray<LegItem>( );
this.LegConstructor.DataBind( );
}
So this way I rebuild the values for each leg and rebind with the new list.
The problem: I have to hit the button twice to get the new entry to display! What am I missing to force the page to display the new data once I complete my response to the event?
Thanks again,
Michael
|
|
|
|
|
Why are you going through all of this
Maintain your collection (as in ViewState, Session, etc.), add one to it in the handler, then rebind. What is the dictionary for? You are only using the values from it.
Michael Eber wrote: I AM NOT AN ASP.NET Coder.
Whether you are an ASP.NET coder or not, someone with your professed skills and length of C# history should be able to figure this out. After writing a new multitasking operating system in Assembler this should be a walk in the park.
only two letters away from being an asset
|
|
|
|
|
Sorry but I'm accustomed to writing code that is stateful where I can just access the datasource, cast it, and append to it. Web coding is a completely different animal. Regardless of HOW I am doing it, whether I figure out how to use ViewState or if I figure out Session, it does not change the fact that when I set my datasource and rebind it, my controls are not displaying until I hit the button twice, or slowly walk through the code in debug mode. Why is this happening? In a real application (ie. not a freaking web p.o.s.) this is always easily figured out. But I cannot figure out why I must hit the button twice to see my control. You say just rebind it. Well I am rebinding the fracking array. And it is not doing it. If you have something USEFUL to add, please I'm all ears. But if you don't then thank you for at least getting me this far.
|
|
|
|
|
Oh yes...another reason for doing this is to get the responses in all of the textboxes.
Does that pass back in Viewstate as well?
I dug through two obvious routes (control and Page) but nothing is there to access ViewState.
|
|
|
|
|
|
Thank you for a usable answer. So it seems that the viewstate is updated prior to reaching my method ... that adds the new control. So it appears that for the webpage if I instantiate the viewstate update method after binding, then the control should show properly on the outbound process.
|
|
|
|
|
A true professional would have been able to research this for themself
only two letters away from being an asset
|
|
|
|