Forms Data Controls :: Keeping Custom Properties In GridView Added On OnRowDataBound Event While Sorting

Sep 14, 2010

All of my columns are bound in the Gridview. On OnRowDataBound event, I am adding some custom styles like underlines and colors to the text of the columns. Sorting of data is working fine but I am losing my custom styles when I sort. I am using the generic sorting code for the GridView.

How I can keep my custom styles on sorting that I added during OnRowDataBound event.

View 4 Replies


Similar Messages:

Forms Data Controls :: OnRowDataBound Or Custom Protected Method GridView Databind?

Jan 6, 2010

In a GridView control ASP.NET

OnRowDataBound="gvTest_OnRowDataBound" followed by
protected void gvTest_OnRowDataBound(....){}

OR

Text='<%# BindMyData(DataBinder.Eval(Container,"DataItem.Price"), DataBinder.Eval(Container,"DataItem.CurrencyID")) %>'

followed by

protected string BindMyData(object price, object currencyID)
{...}

Which one is best in terms of performance and coding best practice?

View 1 Replies

Data Controls :: What Is GridView OnRowDataBound Event When It Is Used

Jun 6, 2013

What is GridView Event "RowDataBound" ?

When it is used ? And How ?

View 1 Replies

Forms Data Controls :: Getting The Custom Sorting And Paging With Images To Indicate The Sorting Direction In Gridview

Jul 18, 2010

Moderators Note: THIS ISSUE IS BIG FOR ME AND EVEN IF POSSIBLE, GET THE REPLY FROM THE DESIGNER OF GRIDVIEW. I have been looking for him for long. I am really fed up with reviewing a good lot of web pages on how we can possibly customize the gridview to enable sorting and paging. So many sites have listed out a lot of information and so many guidances. But the problem is that one works out fine and the other is a burden. I really feel bad about being given the job of customizing this kind of a gridview which has no user friendly approach to it. Also, this control is rendered without the pager links inside the <tfoot> tag. I have tried the Pear Pager in php. It is that good and easy to use and compared to that, the gridview in asp.net is the worst ever control i have ever tried so far.

1. i can use the images to indicate the sorting direction
2. I can have the custom pager like

[code]

<<Previous 1 2 3 .. 7 Next >>.

[/code]

When i click the next when i am viewing the page at 3 , the pager links should change as

[code]

<<Previous 2 3 4 .. 7 Next >>

[/code]

Kindly look into this type of requirement and firstly tell me whether this is possible with the gridview control. I would like this request even to be escalated to the designers of the gridview control also, so that Microsoft comes out with a reply THAT WORKS and not the kind of stuff like surfing through a lot of links and pages and finally wasting a lot of days precious time and still breaking the head with this useless control. I have spent a lot of time in searching for a perfect way. Not writing a code that is non-standard. I am really serious b'cos I have spent weeks in customizing this control. If I dont get a solid reply atleast now, I am going to generate all the output by HTML content by custom coding.

View 7 Replies

GridView Doesn't Contain Control Added In OnRowDataBound?

Nov 9, 2010

I can't get control which I added in DataGrid. I am adding it in OnRowDataBound event like:

protected void RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState == (DataControlRowState.Alternate | DataControlRowState.Edit))

//int cindex = 0;
//for (cindex = 0; cindex < e.Row.Controls.Count; cindex++)
foreach (Control ctl in e.Row.Controls)
{
DataControlFieldCell dcctl = (DataControlFieldCell)ctl;
TableCell tcell = (TableCell)dcctl;
Label lblComment = new Label();
TextBox txtComment = new TextBox();
lblComment.Text = "<br>Comment: ";
dcctl.Controls.Add(lblComment);
dcctl.Controls.Add(txtComment);
//tcell.Controls.Add(lblComment);
//tcell.Controls.Add(txtComment);
//e.Row.Cells[cindex].Controls.Add(lblComment);
//e.Row.Cells[cindex].Controls.Add(txtComment);

What is happening here: there is already exist one TextBox in TableCell by default and I want to add another one TextBox and Label. After the bounding I can see 2 textboxes, I can input data into the both, but when I click Update button, then raises OnRowUpdating event where I can't get my TextBox!

protected void RowUpdating(object sender, GridViewUpdateEventArgs e)
{
grdView.EditIndex = -1;
int counter = 0;
for (counter = 0; counter < grdView.Rows[e.RowIndex].Cells.Count; counter++)
{
foreach (Control ctl in grdView.Rows[e.RowIndex].Cells[counter].Controls)
{

And here I will be getting only default one TextBox (with its value). But my TextBox is disappeared! :(

P.S. I can't use predifined columns, like asp:TemplateField in aspx file, because my table has different amount of rows every time. It is dynamic

View 3 Replies

Custom Server Controls :: Usercontrol Lose All Its Properties When Dynamically Added By Code

Jan 10, 2011

when I add a custom usercontrol by code like this:

[Code]....

the compiler doesn't accept it at all...

how to access "custom usercontrol's properties" while the usercontrol itsef has been added programaticly by code.

View 9 Replies

Web Forms :: Bind DropDownList In ItemTemplate Of GridView In OnRowDataBound Event?

Aug 31, 2012

how to bind dropdownlist in gridview in row databound event in asp.net?

View 1 Replies

Forms Data Controls :: ObjectDataSource - Custom Gridview Paging And Sorting?

Feb 4, 2010

ObjectDataSource - Custom Gridview Paging and Sorting?

View 2 Replies

Forms Data Controls :: GridView - EntityDatasource And Entity Custom Properties Using Partial Class

Apr 25, 2010

I'm face of a little problem when using GridView, an EntityDatasource and entity custom properties using a partial class. I'll describe it and I hope that someone has already find the solution because I try to figured out since two days.

View 4 Replies

Forms Data Controls :: Gridview Fired Sorting Event Without Handle On Statement "helper.ApplyGroupSort()

Jan 25, 2010

I have problem with gridview sorting. I am using online example to sort a grid view. see the link [URL] but I always got an error "The gridview fired sorting event without handle" on this statement "helper.ApplyGroupSort();"

<table width="100%">
<tr>
<td colspan=3><asp:Label id="category_name" Runat="server"
ForeColor="#ff0000" Font-Bold=true /></td>
</tr>
<tr>
<td colspan="3" align="center" width="100%">
<asp:GridView ID="dg_drawings"
runat="server" AutoGenerateColumns="False" EnableViewState="False" CellPadding="5" CellSpacing="0" Width="90%"
>
<Columns>
<asp:BoundField DataField="Description"
SortExpression="Description" />
<asp:BoundField DataField="sub_description"
SortExpression="sub_description" />
<asp:BoundField DataField="drawing_id" InsertVisible="False"
ReadOnly="True"
SortExpression="drawing_id" />
<asp:BoundField DataField="DRAWING_DESCRIPTION"
SortExpression="DRAWING_DESCRIPTION" />
<asp:BoundField DataField="DWG_URL" SortExpression="DWG_URL" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>

Here is my C# code

public partial class listDrawings : System.Web.UI.Page
{
admin _admin = new admin();
private GridViewHelper helper;
int categoryid = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["logged_in"]) == "1")
{
ph_header.Controls.Add(LoadControl("../controls/builder_header.ascx"));
}
else
{
ph_header.Controls.Add(LoadControl("../controls/header.ascx"));
}
/*if (Convert.ToString(Session["details_hit"]) != "1")
{
_admin.add_page_hit("Standard Details");
Session.Add("details_hit", "1");
}
*/
string categoryidStr = Request.QueryString["categoryid"];
string category = Request.QueryString["category"];
//int categoryid = 0;
if (categoryidStr != null)
{
categoryid = Convert.ToInt32(categoryidStr);
}
category_name.Visible = true;
category_name.Text = category + " Drawing Details";
get_category_drawings(categoryid);
}
protected void get_category_drawings(int categoryid)
{
OracleConnection myConn;
OracleCommand myCmd;
if (categoryid == 3)
{
myConn = new OracleConnection(ConfigurationManager.AppSettings.Get("oracle"));
myCmd = new OracleCommand("DRAWINGS.GET_STAR_SUB_DRAWINGS");
myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Connection = myConn;
myCmd.Parameters.Add(new OracleParameter("iCATEGORY", OracleDbType.Int32, ParameterDirection.Input)).Value = categoryid;
myCmd.Parameters.Add(new OracleParameter("iSUB_CATEGORY", OracleDbType.Int32, ParameterDirection.Input)).Value = 0;
myCmd.Parameters.Add(new OracleParameter("oDRAWINGS", OracleDbType.RefCursor, ParameterDirection.Output));
}
else
{
myConn = new OracleConnection(ConfigurationManager.AppSettings.Get("oracle"));
myCmd = new OracleCommand("DRAWINGS.GET_STAR_DRAWINGS");
myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Connection = myConn;
myCmd.Parameters.Add(new OracleParameter("iCATEGORY", OracleDbType.Int32, ParameterDirection.Input)).Value = categoryid;
myCmd.Parameters.Add(new OracleParameter("oDRAWINGS", OracleDbType.RefCursor, ParameterDirection.Output));
}
try
{
myConn.Open();
this.dg_drawings.DataSource = myCmd.ExecuteReader();
dg_drawings.DataBind();
helper = new GridViewHelper(this.dg_drawings);
string[] cols = new string[2];
cols[0] = "Description";
cols[1] = "sub_description";
helper.RegisterGroup(cols, true, true);
helper.ApplyGroupSort();
}
catch (OracleException ex)
{
if (categoryid == 3)
{
_admin.send_email("resources/listDrawings.aspx", "DRAWINGS.GET_STAR_SUB_DRAWINGS", ex.Message);
}
else
_admin.send_email("resources/listDrawings.aspx", "DRAWINGS.GET_STAR_DRAWINGS", ex.Message);
Response.Redirect("~/error.aspx");
}
finally
{
myCmd.Dispose();
myConn.Close();
myConn.Dispose();
}
}
}

View 5 Replies

Custom Server Controls :: Why Custom Gridview Control Not Render HTML Properties Under Properly In Visual Studio 2005

Mar 5, 2010

Why custom Gridview control not render html properlies under <Columns> properly in Visual Studio 2005?

For example:

[code]....

View 1 Replies

Forms Data Controls :: The GridView "GridView1" Fired Event Sorting Which Wasn't Handled

Mar 23, 2010

I googled and found this post : [URL] I have never had this problem b4. I just started a new job, do i need a service pack update or something?

DataTable dt;
DbCommand cmd = GenericDataAccess.CreateCommand_SP("rptPlannedActivity");
GenericDataAccess.AddParameter(cmd, "@Outstanding", DbType.Int16, 1);
GenericDataAccess.AddParameter(cmd, "@Period", DbType.Int16, 45);
dt = GenericDataAccess.ExecuteSelectCommand(cmd);
GridView1.DataSource = dt ;
GridView1.DataBind();

View 3 Replies

Forms Data Controls :: Error - Gridview Fired Event "Sorting" Which Wasn't Handled Using Visual Studio 2008

Feb 21, 2010

I have a gridview in an update panel which is declared in an ASPX page, and bound to a SQLDataSource in code. The gridview's 'allowsorting' attribute is set to true, and because it is bound to a SQLDataSource, I expect the sorting to be automatically handled.

Yet I am getting the "Message: Sys.WebForms.PageRequestManagerServerErrorException: The GridView 'grdStatusItems' fired event Sorting which wasn't handled" error. I am using Visual Studio 2008, IE8, IIS7. What am I doing wrong? I have done anextensive search for this error, but it seems in most cases where this error occurs, the people are not using a SQLDatasource, so have to handle the sorting event themselves. Is this the case here? Here is the updatepanel and gridview declaration in the aspx file:

[Code]....

View 1 Replies

Forms Data Controls :: Combining OnRowDataBound And OnRowCommand Events Causes OnRowCommand Not To Fire For GridView?

Jul 1, 2010

I'm using a standard GridView control inside of a web form. The web form uses a master page. The application is running within sharepoint (wss 3.0) environment. When i attach both the OnRowCommand and OnRowDatabound events to the gridview as shown in the markup below, only the OnRowDataBound event fires. The OnRowCommand never gets hit. When i press a button on a row, it posts back but never hits the onRowCommand event and simply falls through and repaints the page . However if i remove the OnRowDataBound event, the OnRowCommand event starts to fires correctly. I've tried a number of things...1. Hooking up the events in code instead of markup. (inside of PageLoad or PageInit)2. Changing the order in which the events are attached.

View 4 Replies

Custom Server Controls :: Paging And Sorting Gridview Custom Control Inside Of A Wizard Control?

Dec 24, 2010

here's a situation and I would appreciate your response.

I have programmatically created the Wizard control:

Page_Load(obj s, evargs e)
{
Wizard ClaimDetailWizard = new Wizard();
foreach(int item in selectedItems)
{
//create new step
//added custom control to new step
//add step to wizard
}
//added wizard to a placeholder on a page
}

Based on List I get from Session i added new steps to my wizard To each step I had added a custom control

Each custom control in tern contains another custom Gridview Control in it.

So here's the problem when the page loads for example for two steps. All is good Wizard does what it's supposed to do.

But when I try to use sorting or paging in that custom Gridview. Somehow it displays the gridview I should see in the next step of the wizard.

Also what I'm noticing through debugging. Is that when I press next in the wizard I go back to the original page where I do all of the code specified above, and it recreates the wizzard. But it goes to the next step. Is this the way wizard supposed to work? Just doesn't seem very efficient.

View 1 Replies

Forms Data Controls :: Default Sort "The GridView "GridView1" Fired Event Sorting Which Wasn't Handled

Feb 19, 2010

I have a page displays CRM data (with CrmService) in GridView. Everything run ok until I tried to sort out one field by default and I received the following exception: The GridView 'GridView1' fired event Sorting which wasn't handled. The reason I am using GridView to do the sorting because:

1) Cannot do it with SQL "ORDER BY" since date retrieval from CRM Web Service

2) Cannot use OrderExpression for QueryExpression from CRM because the column I want to sort is generated by my algorithm

GridView1.Sort("ColumnName" SortDirection.Descending);
in Page_Load, or Button1_Sort(object sender, GridViewSortEventArgs e), they all trigger the above execption!

I also added the method to the following method to handle exception, but didn't work:

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
GridView1.Sort("ColumnName" SortDirection.Descending);
}

View 2 Replies

Forms Data Controls :: Custom GridView ImageButton Click Event Handler Not Firing?

Feb 10, 2011

I am trying to create a custom GridView with a header toolbar at the top that will contain icons to export the grid view to different formats like excel, word, etc.. The problem is, I cannot get the method to fire that is assigned to handle the click event for the corresponding Image Button. The page posts back, but the code I have in the method to handle the click event does not fire. I have followed examples in other posts and from what I can tell I have followed what others have done. Can somebody take a look at see if they can find something that I am doing wrong.

[Code]....

View 1 Replies

Forms Data Controls :: Keeping A Running Total Of Entries In Gridview?

Jul 29, 2010

I have a bulk editable gridview. I want to find a way of keeping a running total up to 100 in each row when the user is entering values into the editable columns. I then want to save this data.

The running total column (Total) is a bound column and not editable by the user.

View 6 Replies

Forms Data Controls :: Added Datalist Imagebutton Event?

Oct 4, 2010

i have taken a data list.in that i have added a imagebutton field that is bind to a image field of database.i want that when the image is clicked from the datalist that should be shown to the other image field in web page

View 4 Replies

Web Forms :: Custom Sorting In Gridview

Apr 12, 2010

In grid view we have option by default as sorting and paging. if i disabled those two textboxes by pro grammatically i need to get that feature.

View 2 Replies

Forms Data Controls :: Database Updates But Gridview Doesn't After Custom Button Click Event?

Feb 8, 2010

So I followed Scot Mitchell's tutorial from asp.net/learn on adding a checkbox column to be able to select multiple entries and delete them with the click of a button. When I make my selection and click the button it works on the database end, as the desired entries are deleted. However, the entries remain on the page after it reloads. if I refresh the page it's updated properly but I'd like it to automatically update after the button is clicked.

Also, I tried his method for adding check/uncheck all buttons to the top of the gridview and they don't seem to be working either.

Here's the code behinf from the gridview page:

[Code]....

View 2 Replies

Forms Data Controls :: Gridview Paging, Keeping Checked Values Of Checkbox?

Mar 29, 2010

I got a list of customers That I'm gone show in the gridview. I have added a checkbox infront of every customer so i can select what customers gone be used and passed to the next method. With a little bit of strugle I almost got everything working now except for this thing with keeping the values of checked customers when I page to the next page (2,3,4,5 ect).

View 1 Replies

Forms Data Controls :: Dropdownlist In Gridview Not Keeping Data Value?

Nov 4, 2010

I've got a gridview which contains a dropdownlist. I've got it binding to display the correct name, but when I go to update it (and it could be the dropdownlist field or any other the other fields), I get an error stating it can't update the row because
addr_cnt doesn't allow null fields. I've tried just about everything I can find to get it to keep the addr_cnt value, but nothing seems to be working. My code is below:

<asp:GridView id="gvLeader" runat="server" AutoGenerateColumns="False" datakeynames="ldr_id" DataSourceID="dsLeaders" GridLines="Vertical">
<Columns>

[code]....

View 7 Replies

Forms Data Controls :: Detect Last Row In 'onrowdatabound'?

Jun 15, 2010

I've got a problem with my onrowdatabound function. The situation is like this:

protected
void gvSQL_RowDataBound(Object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
switch (Session["Filter"].ToString())
{
case "NonZero":
if (e.Row.Cells[9].Text == "0")
{
e.Row.Visible = false;
}
break;
}
}
}

At the end I need to kill the Session, so my plan is to detect if it reaches the last row. Then I can kill it. Does anyone know how to do this? Or is there someone that knows a better to fix this?

View 6 Replies

Forms Data Controls :: Find Control Added To PlaceHolder During OnItemDataBound Event

Jul 15, 2010

I add one or more textbox controls to a repeater itemtemplate during OnItemDataBound.

The textbox controls are instantiated and then added to a placeholder.

My problem is getting the user entered values from those dynamically added textboxes. They do not seem to exist in the repeater items collection.

[Code]....

[Code]....

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved