I have a gridview which takes inputs from a textbox. Multiple values can be added to it. I want to rest the grid. I have tried few codes in the internet. But just clear the grid. When i type the numbers again all the previous numbers appear. I want to remove previous numbers too when i reset the grid. How can i do it?
Here is my back end code
if (grdPolicyDetails.Rows.Count > 0)
{
grdPolicyDetails.Columns.Clear();
grdPolicyDetails.DataBind();
}
I have tried this code too. This too didn't work.
grdPolicyDetails.DataSource = null;
grdPolicyDetails.DataBind();
Are you talking about the History of Browser ? if yes then,
If Clear Gridview Data then,
grdpolicydetails.Controls.Clear();
Related
I'd like to "hide" one column in my RadGrid and only have it show when I'm in edit mode. I tried just moving it into the edit item template, but that didn't work at all.
Any suggestions would be deeply appreciated!
Thank you!
Oy...
"Paul's Third Law of Asking For Help
You will discover the obscure answer 5 minutes after giving up and asking for advice."
Turns out you set the column to "Display=False" but only if you are in popup or edit form mode, not inline.
Hope it helps someone else.
Even though you did answer this yourself I thought I'd write an answer to clarify some things.
You can set the default value of the EditColumn to be false, even in InPlace edit. However it makes it a lot more difficult to save edited data as the InPlace edit (for simplicity) requires the EditColumn to display the save or cancel items.
That being said, you can do it - however you need to use explicit CommandNames on the items:
Say you want to Update a row with the new values you have inserted in the InPlace edit. Then the confirm button's CommandName would HAVE to be "Update" to be picked up correctly.
All of this being said, it would be a lot simpler for you to keep the EditColumn intact even when in InPlace (editmode).
Or you could specify the EditTemplate for one column to widen the column, add the two buttons necessary to perform Update and Cancel as well as hiding the EditColumn so that multiple InPlaceEdits can't be performed at the same time. :)
I hope this helps someone, as I was stuck in a similar situation myself when I had to incorporate both InPlace and EditForms EditModes on a single RadGrid and knowing the above information made a WORLD of difference.
You can try this:
var agtype = $telerik.$(atCell).text().trim();
if(agtype == ""Guaranty""){{
var masterTableView = sender.get_masterTableView();
var columnIndex = masterTableView.getColumnByUniqueName(""Amount"").get_element().cellIndex;
masterTableView.showColumn(columnIndex);
}}
I don't understand how QTable::editCell() should be used. I am trying to do some error checking based on entries made by user in a QTable as mentioned in my another question.
I would like to give user an opportunity to re-edit the cell which has error. For example, if name column entry has some special characters such as '(', the user should be prompted for the error and the control should go back to same cell in edit mode. I tried using QTable::editCell() in my code as shown below.
Table->editCell(row, 0, TRUE);
name = Table->text(row, 0);
However, this doesn't work as expected. The control doesn't stay in the cell at all and obviously the name is not correctly collected. So, my question is how to ensure from within code that a cell of QTable can be edited so that the edited contents can be accessed immediately in next statement (as shown in above code).
Note: I am working with qt 3.3.8 only.
I don't think you can do that. You'll have to go back to the event loop, and wait for one of the signals (like valueChanged(row,col)) to be fired to re-validate the data.
A blocking wait on a GUI object is often not a good approach (except for modal dialogs).
I know I'm a little late here but you should use the following connect statement with your own custom function to do your specific needs such as below. You can also use this method to disable users from entering in special characters within you custom function. That way they wont ever have to correct undesirable characters.
connect(ui->tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(customFunction(int,int)));
void updateTable
{
//remove invalid characters
}
I have a weird issue that I am being asked to fix but alas I have thus far drawn a blank. As the title suggests I am trying to get the tab order for two text boxes to follow one after the other.
The idea is (and this is inherited code rather than that of my own design) that a routine is call that builds atable cell inserting two text boxes and one link. This is then returned and foreach line in the table a new copy of this cell is generated.
I have tried setting the TabIndex for the text boxes and find that when I tab I only get as far as the first box (txtPound) and never the second (txtPence).
I can't decide if the issue is due to trying to do this in a TableCell or whether its something else completely.
Hopefully that's clear but should you require any further info then I will try to supply it.
I have included a striped down version of the code below, essentially this gets added to a table row in a the aspx pace.
Any help would be greatly appreciated.
private TableCell EstimateInputs(Brief item)
{
TableCell td = new TableCell();
TextBox txtPounds = new TextBox();
string[] agencyCosts;
txtPounds.TabIndex = 1;
td.Controls.Add(txtPounds);
//td.Controls.Add(new LiteralControl("<span>.</span>"));
TextBox txtPence = new TextBox();
txtPence.MaxLength = 2;
txtPence.TabIndex = 2;
td.Controls.Add(txtPence);
td.Controls.Add(new LiteralControl("</p></fieldset>"));
}
So it ended up being a complete red herring. turns out that there was a little JavaScript function that is applied to text boxes that deal with monetary values. it stops anything other than a numerical key press which means it includes the tab key.
So the mystery is solved - thanks for the help.
I have a QTableWidget and I want to disable the behavior that a row or column is selected when you click on a row or column header.
Does anyone know how to disable this behavior?
Edit:
The headers need to remain clickable, because the onClick-function is needed.
You might want to disconnect the selectColumn slot from the sectionPressed signal of the header, something along the lines:
disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)),this, SLOT(selectColumn(int)));
QTableWidget::setSortingEnabled(true);
This eliminates the column selection behavior you describe and trades it in for sorting by column!
There are several several ways to do it
The simple way that is not so good :) (and depends on Qt implementations as everything :):
in the table view its horizontal header sectionPressed(int) is connected to table selectColumn(int), so you can simply disconnect them :( (the same sure for vertical header)
You can ipmlement the table view virtual selectionCommand(const QModelIndex&, const QEvent* event) interface and return "no selection" if event is 0 (as it's a 0 then while clicking on header area)
And finally the best and original solution: You can have and then set your own selectionModels both for table and its header (or headers) and re implement the selection behaviors as you want.
tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
This property holds which selection mode the view operates in. SelectionMode
Or maybe you need tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows )
This property holds which selection behavior the view uses.
SelectionBehavior
you can try setting false to the function setClickable
QTableWidget::horizontalHeader()->setClickable(false);
If this works, then you can do the same for [verticalHeader][2]
[2]: http://doc.qt.nokia.com/latest/qtableview.html#verticalHeader "verticalHeader"
I know the answer to this question.
disconnect(yourTableWidget->horizontalHeader(), SIGNAL(sectionPressed(int)),yourTableWidget, SLOT(selectColumn(int)));
for example:
QTableWidgetItem * p_wgtitm = this->ui->tblwSome->item( 0, 0 );
int flags = p_wgtitm->flags();
flags &= ~(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
p_tblitm->setFlags( (Qt::ItemFlags)flags );
If Qt for Python is acceptable, it worked for me by doing this:
def setModel(self, model):
super().setModel(model)
self.horizontalHeader().sectionPressed.disconnect()
Apparently the signal was getting connected in setModel. I just disconnected from everything.
I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:
I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an option. The other set does also but for a different purpose. But only one set can have a selected radiobutton.
Ok I've tried this using 2 asp.net Radiobuttonlists controls on the same page. Got around the nasty bug with GroupName (asp.net assigns the control's uniqueID which prevents the groupname from ever working because now, 2 radiobuttonlists can't have the same groupname for all their radiobuttons because each radiobuttonlist has a different uniqueID thus the bug assigns the unique ID as the name attribute when the buttons are rendered. since the name sets are different, they are not mutually exclusive). Anyway, so I created that custom RadioButtonListcontrol and fixed that groupname problem.
But when ended up happening is when I went to put 2 instances of my new custom radiobuttonlist control on my .aspx page, all was swell until I noticed that every time I checked for radiobuttonlist1.SelectedValue or radiobuttonlist2.SelectedValue (did not matter which I was checking) the value always spit back string.empty and i was not able to figure out why (see http://forums.asp.net/t/1401117.aspx).
Ok onto the third try tonight and into the break of dawn (no sleep). I tried to instead just scrap trying to use 2 custom radiobuttonlists altogether because of that string.empty issue and try to spit out 2 sets of radiobuttonlists via using 2 asp.net repeaters and a standard input HTML tag inside. Got that working. Ok but the 2 lists still are not mutually exclusive. I can select a value in the first set of radiobuttons from repeater1 and same goes for repeater2. I cannot for the life of me get the "sets" to be mutually exclusive sets of radiobuttons.
As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.
The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values so that you easily identify from which list the option comes.
Update: based on the new info posted as an answer. The option I proposed on my original answer corresponds to the 3. You really must consider the following:
Html radio buttons have only 1
built-in mechanism to handle the
exclusivity, which is the name.
You are explicitly requesting a no js solution, so given the above you must manipulate the Ids to achieve it. If you weren't blocking this option I am sure someone would come up with some nice jquery or js library that already supports it.
The option 3 is clearly the less invasive, as you are not forced to affect the actual data, and are not affected by future updates to it.
It's not that much code, just something extra on the List indexes, and some simple thing as:
int? list1Value = null;
int? list2Value = null;
var value = Request.Form["somegroup"];
if (value.StartsWith("List1"))
list1Value = int.Parse(value.Substring(5));
else
list2Value = int.Parse(value.Substring(5));//Assuming List2 as prefix
Original:
I saw your other question, and you just need to use the same group name. Make sure you have different values for all items regardless of the list they come from. A way to achieve this is adding something to the values, like: <%# "List1-" + Eval("ID") %> and modifying the code that reads your Request.Form["yourgroupname"].
I think you should just use RadioButtons instead of RadioButtonLists.
Here's an article that presents a solution to resolve the radiobutton naming bug.
Though this post is dated 1 year ago already, I just read it because I face the same problem.
Currently I have 1 solution using jQuery:
Client side script (you must also include jQuery)
function SetRadio(rb) {
$('input:checked').attr('checked', false);
rb.checked = true;
}
For every radiobutton (which is a listitem in a radiobuttonlist) I add the following on the serverside:
li.Attributes.Add("onclick", "javascript:SetRadio(this)");
For me this works in both IE and Firefox, with 3 radiobuttonlists, without using groupnames.
You can check each radiobuttonlist for a selecteditem/value, or you can extend the SetRadio function so it stores the selected value in a hidden field.
Regards,
M