I have been working with Telerik RadGrids and I haven't had any problem setting all items to edit mode when I'm populating the grid.
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem)
{
e.Item.Edit = true;
}
}
Now I'm working with a Telerik RadTreeList and I would like to do something similar. Is it any possible way to do this? As far as I have been searching, I haven't found any possible solution for this.
Did you check at http://www.telerik.com/help/aspnet-ajax/treelist-server-side-basics.html?
RadTreeList has an ItemCreated event as well.
Can you try?
protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
{
if (e.Item is TreeListDataItem)
{
TreeListDataItem item = e.Item as TreeListDataItem;
item.Edit = true;
}
}
The solution goes as follows:
protected void RadTreeList1_PreRender(object sender, EventArgs e)
{
if (!IsPostBack)
{
foreach (TreeListDataItem item in RadTreeList1.Items)
{
if (item is TreeListDataItem)
{
item.Edit = true;
}
}
RadTreeList1.Rebind();
}
}
The (!IsPostBack) condition would depend on if the TreeListDataItem get's populated at Page_Load.
Related
I have a radioButton list and I want to set 0 as default index.
But,when page is posted by other button ,radiobuttonListChanged event is firing automaticly.
What should I do ?
protected void Page_Load (object sender, EventArgs e)
{
rblList.DataSource = MyDataSource();
rblList.DataBind ();
if (!IsPostBack)
{
rblAccounts.SelectedIndex = 0;
}
}
protected void rbl_Changed (object sender, EventArgs e)
{
Response.Write("Change Event fired");
}
In rbl_Changed event Write following code probably will help you out.
rbl.changed-= rbl_Changed;
rbl.changed = false;
rbl.changed+= rbl_Changed;
I am trying to hide a row when its button clicked in my gridview. Does anyone have a solution for this, I am all yours,
Code behind:
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removethis")
{
Guid id = Guid.Parse(e.CommandArgument.ToString());
UsersBL.DeleteUserByUserId(id);
}
else
{
//hide the row
}
}
try this - Add RowDataBound event and do like this:
e.Row.Visible = false;
You need to access the row-object and then you can hide it, it's a little tricky:
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removethis")
{
GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
row.Visible = false;
}
}
I'm trying to get the value of radio button selection to my listbox, but the listbox always gets the same value even though selection was different. Please help, I am a newbie to coding, I couldn't find any answers on the net either..
Here are the codes I've written:
void rdbtnOne_CheckedChanged(object sender, EventArgs e)
{
if (rdbtnOne.Checked == true)
{
rdbtnOne.Text = "Men";
}
else
{
rdbtnOne.Text = "Women";
}
}
void btnOne_Click(object sender, EventArgs e)
{
lstOne.Items.Add(i + rdbtnOne.Text);
i++;
}
Ok, I have found the solution, FINALLY. The reason that my code did not work in the first place was because I tried to give value by equaling rdbtnOne.Text directly. Instead I created another value to equal it. All right here is how it worked for me:
string MenOrWomen;
void rdbtnTwo_CheckedChanged(object sender, EventArgs e)
{
if (rdbtnTwo.Checked.Equals(true))
{
MenOrWomen = "Women";
}
else
{
MenOrWomen = "Men";
}
}
void rdbtnOne_CheckedChanged(object sender, EventArgs e)
{
if (rdbtnOne.Checked.Equals(true))
{
MenOrWomen = "Men";
}
else
{
MenOrWomen = "Women";
}
}
int i = 1;
void btnOne_Click(object sender, EventArgs e)
{
lstOne.Items.Add(i + MenOrWomen);
i++;
}
I have a strange problem with DataGrid context menu. I load item details from server after click on a item in datagrid. While loading the details the application shows a waitscreen:
private void gridViewOrders_MouseDown (object sender, MouseEventArgs e)
{
GridView gv = sender as GridView;
if (gv != null)
{
ShowWaitScreen (message);
GridHitInfo ghi = gv.CalcHitInfo (e.Location);
...
CloseWaitScreen ( );
}
}
When the user click the right mouse button, it should shows a context menu:
private void gridViewOrders_PopupMenuShowing (object sender, PopupMenuShowingEventArgs e)
{
if (e.MenuType == GridMenuType.Row)
{
DXMenuItem item = new DXMenuItem ("Delete", OnBtnDeleteOrder_Click);
e.Menu.Items.Add (item);
}
}
But the menu disappear at once. When I remove the waitscreen, the context menu is shown and the user can select the "Delete" menuitem. Any hints, how I can fix this problem? Thank you!
A good solution for my problem is to do the following:
private void gridViewOrders_MouseDown (object sender, MouseEventArgs e)
{
GridView gv = sender as GridView;
if (gv != null)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
ShowWaitScreen (message);
...
CloseWaitScreen ( )
}
}
}
Thanks to the DevExpress team for the hint!
I dont really thisnk you need to handle anything in MouseDown event.
This code works for GridView:
private void gridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
GridView view = sender as GridView;
if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Row)
{
int rowHandle = e.HitInfo.RowHandle;
e.Menu.Items.Clear();
DXMenuItem zaznaczItem = new DXMenuItem("Zaznacz wszystkie", new EventHandler(zaznacz_Click));
DXMenuItem odznaczItem = new DXMenuItem("Odznacz wszystkie", new EventHandler(odznacz_Click));
e.Menu.Items.Add(zaznaczItem);
e.Menu.Items.Add(odznaczItem);
}
}
void zaznacz_Click(object sender, EventArgs e)
{
foreach (DataRow dr in (gcKontrahent.DataSource as DataTable).Rows)
{
dr["checkbox"] = true;
}
}
Handler zaznacz_Click is just example of handler for selected menu item. odznacz_Click is similar so I didnt post it. I dont have example for DataGrid so excuise me if it's not good solution. Just take it as example for acomplishing context menu handling in GridView.
I am trying to clear the contents of a listbox when a new tab is seleced. Here is what I got, but nothing happens.
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabControl1.TabPages["entryTab"])
{
readBox.Items.Clear();
reminderBox.Items.Clear();
}
}
Try something like this in your form load
tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_SelectedIndexChanged);
// Try this set null to DataSource
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabControl1.TabPages["entryTab"])
{
readBox.DataSource = null;
reminderBox.DataSource = null;
}
}