|
Hi guys, i have a datagrid with a check box.
when user clicks 'Delete' button, then all the rows
where a checkbox is checked should be deleted.
here is what i have tried and suprisingly only the first selected row get
deleted and the rest are ignored
CheckBox delSel;
for (int i = 0; i < contacts.Items.Count; i++)
{
delSel = (CheckBox)contacts.Items[i].Cells[1].FindControl("delSelection");
if (delSel.Checked)
{
string contactId = contacts.Items[i].Cells[0].Text;
string delet = manager.DeleteContact(contactId);
}
}
Please help if you know how i can delete all checked rows(contacts)
Thanks,
Morg
|
|
|
|
|
It should delete all the selected rows.Try to debug it you will get to know the reason.There might b some problem in logic.
After deleting all the rows bind your grid with fresh data again.
|
|
|
|
|
Ya managed to fix it...really just logic wasted my 3hours.
I was calling a method to update my datagrid within the forloop,
to mean when it loops once i call the method to update datagrid
hence my selected/checked items get refreshed and lost.
So irritating
Anyway thanks for your help
|
|
|
|
|
it happens sometimes
|
|
|
|
|
DataGridDemo[^]
Look at the section Checkboxes and TextBoxes
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi,
currently i m working in asp.net 2.0 (2005).
1st time i m using the previousPage process.i tried to retrive a hidden variable (source page) value to my destination page.
1. i set the PostBackURl as my destination page on the button click on source page
2. i put the following coding in the destination onload event.
if ((PreviousPage != null) && (PreviousPage.IsCrossPagePostBack))
Label1.Text = System generated ID : " + Convert.ToString(PreviousPage.FindControl("HidTest"));
but always the PreviousPage is null and not coming inside the loop.
help me please - Karan
|
|
|
|
|
Hi,
you say PreviousPage is always null. When is the code you posted actually run? If it is on a postback,
PreviousPage is null, because there is no PreviousPage then. You should save the value
in a "If(!IsPostback)" part of your page load.
This is just a guess i'm afraid.
Good Luck
|
|
|
|
|
Hello friends,
I have created a report which uses CSS to set back-ground image a text box. When I run the report using ASP.NET CrystalReportViewer, the CSS formatting was applied but when I tried to print the report, the CSS formatting was not applied.
I am using Crystal Report for Visual Studio .NET 2005.
Please help me in solving this issue.
Shivanandan C V
|
|
|
|
|
hii........plz help
.... if i have one image...if i click on buton(i take as buton click event like btngreen_click) i need to change that total image to that green color..can u help me plz....
thanqu fnds...
~anisha~
|
|
|
|
|
Please don't post your question on several forums.
|
|
|
|
|
What kind of image is this, elaborate your question.
Shivanandan C V
|
|
|
|
|
onclick event of button
btn.backgroundcolor=green;
btn.imagehref="";
I think it may help u....
|
|
|
|
|
how to Concatenate values from gridview to textbox in asp.net
i hav a grid n columns are
3 i use that code if (gvProviderCPTFeeNotesEnterNotes.Rows.Count != 0)
{
string Str = string.Empty;
for (int i = 0; i < gvProviderCPTFeeNotesEnterNotes.Rows.Count; i++)
{
for(int j=0; j< 3; j++)
{
string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
string Str2 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
string Str3 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
if (i == 0)
{
txtProviderCPTFeeNoteViewNotes.Text = string.Format("Date: {0}\r\nContent: {1}\r\nUserID: {2}", Str1, Str2, Str3);
Str = txtProviderCPTFeeNoteViewNotes.Text.ToString();
}
else
{
txtProviderCPTFeeNoteViewNotes.Text = string.Format("{0} \r\n\r\n Date: {1}\r\nContent: {2}\r\nUserID: {3}", Str, Str1, Str2, Str3);
Str = txtProviderCPTFeeNoteViewNotes.Text.ToString();
}
}
}
}
|
|
|
|
|
So, are you getting any error or exception with this code?
I didn't understand your question, can you explain a bit.
diyaa_08 wrote: string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
Also, no need to use ".ToString()" as ".Text" property returns a string only.
P.S: Put your code in "pre" tags, it'll enhance the readability.
-- Modified Wednesday, April 28, 2010 2:03 AM
|
|
|
|
|
<i displayed values in grid view than in ither tabpanel i hav to display these values in a textbox with concatenation string how i do that plz tell me>
|
|
|
|
|
First, tell me whether you want to do this on a particular row selected event or for all rows present in your gridview (Your code is doing this)?
|
|
|
|
|
Hi guys.. Im working on a web application on C#.net with VS2003(Framework1.1).. in my page i have a DDL which populates the items from the database... now on my page the user fills a form by selecting the items from the DDL. The user can also edit previous froms, at this stage the datas come from the database and gets filled on the textbox,DDL, radio buttons etc to edit the fields. Now when a data from the database is not present in the DDL list i get an exception to handle this situation i need to set a condition such that it checks if the data from the database is present in the DDL list then it shows in the DDL otherwise it must show the Fist item in the DDL which is "Select an option". so i put up the following condition:
if(ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Value == myDr["BenefName"].ToString())
{
ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Selected=true;
}
else
{
ddl_Benef.Items.FindByText("Select an option").Selected=true;
}
here if the data from the database is present in the DDL the code works fine in case the data is not present in the DDL then it doesnt go to the else condition instead gives me "System.NullReferenceException: Object reference not set to an instance of an object."
Any help or advice is appreciated...
Thanx in advance,
Tash
|
|
|
|
|
<<tash18>> wrote: i have a DDL which populates the items from the database
<<tash18>> wrote: ddl_Benef.Items.FindByText("Select an option").Selected=true;
When there is no item in the database, how do you think that it will find the text "Select an option".
Instead of finding the text, you need to add an item like this:
ddl_Benef.Items.Add("Select an option");
Hope this helps!
..Go Green..
|
|
|
|
|
Hi thanks for ur reply..
actually in my DDL i have set the 1st item as "Select an option" and the remaining items gets populated from the database... now thats not the issue... when i try 2 edit an Existing form, the page loads with the datas from the database at that time it picks up an item from the database and tries to locate that item in my DDL.. what i exactly want is it should not throw an exception if that item is not present in my DDL but instead should display my 1st item which is -- "Select an option"...
Hope u understand rite now..
Thanx in advance..
Tash
|
|
|
|
|
You have to do it in your error handling code.
|
|
|
|
|
I think im not framing my if condition in a proper manner...
plz advise..
Thanx in advance,
Tash
|
|
|
|
|
Debug the code to see if any item exists in the DDL when there is no item received from database. The exception you mentioned tells that you do not have any item in the DDL (not even "Select an Option").
..Go Green..
modified on Wednesday, April 28, 2010 6:11 AM
|
|
|
|
|
thanx for ur reply..
my DDL gets loaded with the items on pageload. so the DDL has items in it.. the If condition that im using is working fine if the item retrieved from the database is present in my DDL, it throws an exception only if that item is not present in my DDL...
if(ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Value == myDr["BenefName"].ToString())
{
ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Selected=true;
}
else
{
ddl_Benef.Items.FindByText("Select an option").Selected=true;
}
Im not sure if my condition in the if statement is properly framed or not...
plz advise..
Thanx in advance,
Tash..
|
|
|
|
|
IMO, you should first check whether your condition in if is returning or not.
Try like this:
if(ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()) != null)
{
if(ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Value == myDr["BenefName"].ToString()) { ddl_Benef.Items.FindByValue(myDr["BenefName"].ToString().Trim()).Selected=true; } else
{ ddl_Benef.Items.FindByText("Select an option").Selected=true; }
}
else
{
}
If that value is not null, then proceed. Otherwise, set your default option as selected
|
|
|
|
|