This is a migrated thread and some comments may be shown as answers.

Dynamic Grid Very Urgent Please

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudipta Burman
Top achievements
Rank 1
Sudipta Burman asked on 12 Sep 2008, 01:41 AM

I  created grid dynamically and placed button on the page.It is working fine except column width when i browse the page first time.
 I am also  displaying seach conditions in RadWindow when user clicks on button.
Note : I created xml file for columns definations and using to generate the bound columns.

1. I am getting extra columns when i click on pager to selct particular page or  column for sort.This is exactly the same number of columns in the grid.
   Let assume, I am displaying 5 columns in grid. It is displaying 10 columns after i clicked on paging or sorting, third time 15 and so on. I am not really sure how and where these columns are creating. the value in extra columns is System.Data.DataRowView.

2.4. I am getting the popup with retry and cancel buttons with the below message when i seach the records other than first page or before selecting the column sort or paging. Can you please advice me on this?
 
To Display the webpage again, Internet Explorer needs to resend the information you've previously submited

If you were making a purchase, you should click Cancel to avoid a duplicate transaction. Otherwise, click Retry to display the webpage again.

3. the sort image is coming second line when i click on column for sort. Can please help me to fix this issue?
4. Select Column with is very large when i browse the first time. But it is adjusting the column width automatically after i click on paging or sorting. Can please help me to fix this issue?

5. I set EnableAjax = true but still it is doing post back. Can please help me to fix this issue?

I pasted code below because i didn't see any buttom for file attachment.

Page 1:
HTML :

<%

@ Page Language="C#" MasterPageFile="~/DealerFinance.master" AutoEventWireup="true" CodeFile="DealerList.aspx.cs" Inherits="Dealer_DealerList" Title="Untitled Page" %>

<%

@ MasterType VirtualPath="~/DealerFinance.master" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<

asp:Content ID="Content2" ContentPlaceHolderID="DealerFinancePlaceHolder" Runat="Server">

<

script language="javascript" type="text/javascript">

function LookupParameter()

{

var popWin = window.open('DealersSearch.aspx','SearchDealer','width=400,height=350,top=100,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=yes,left=200','');

// window.open('/DealersFinanceApplication/Dealer/DealersSearch.aspx', 'Sai', '','');

popWin.focus();

return false;

}

function ParentFormPostBack()

{

__doPostBack(

'btnSearch','');

}

</

script>

 

<table>

<tr>

<td align="left">

<!-- <asp:Button ID="tempbtnSearch" runat="server" CausesValidation="false" OnClientClick="LookupParameter()" SkinID="DisplayButton"

Text="Search" /> -->

<asp:Button ID="btnSearch" runat="server" CausesValidation="false" SkinID="DisplayButton"

Text="Search" />

&nbsp;

</td>

</tr>

<tr>

<td>

<telerik:RadGrid ID="grdDealerList" runat="server" AllowSorting="true" ItemStyle-BackColor= "AliceBlue" AlternatingItemStyle-BackColor="#ffffff" GridLines="None">

</telerik:RadGrid>

<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

</td>

</tr>

</table>

<telerik:radwindow openerelementid="<%# btnSearch.ClientID %>" navigateurl="DealersSearch.aspx"

runat="server" width="400px" height="450px" id="Radwindow4" visiblestatusbar="false"

skin="Mac"></telerik:radwindow>

</

asp:Content>

codebehind:

using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.HtmlControls;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Xml.Linq;

using

Telerik.Web.UI;

using

System.Data.SqlClient;

using

System.Xml;

using

System.Drawing;

public

partial class Dealer_DealerList : System.Web.UI.Page

{

public string searchCondition = "";

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

Master.SelectedDealerTab = 1;

//DealSearchFields dealerSeachFieldsObj = (DealSearchFields)Session["DealerSearchFields"];

//if (dealerSeachFieldsObj != null)

//{

// searchCondition = dealerSeachFieldsObj.DealerNumber;

//}

//else

//{

// searchCondition = "";

//}

//btnSearch.Attributes.Add("onclick", "return LookupParameter();");

//Dynaic code for Rad Grid Starts here

 

}

 

}

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

{

grdDealerList.DataSource = BindGrid();

}

private DataTable BindGrid()

{

string searchCondition = "";

DealSearchFields dealerSeachFieldsObj = (DealSearchFields)Session["DealerSearchFields"];

if (dealerSeachFieldsObj != null)

{

searchCondition = dealerSeachFieldsObj.DealerNumber;

}

else

{

searchCondition =

"";

}

string sql = "SELECT ROW_ID ,DEALER_NUM ,NAME, LEGAL_NAME, SALES_DISTRICT, BUSINESS_TYPE FROM KF_DEALER where DEALER_NUM LIKE '%" + searchCondition + "%' order by DEALER_NUM";

SqlDataAdapter adapter = new SqlDataAdapter(sql,

ConfigurationManager.ConnectionStrings["KC_DealerFinanceConnectionString"].ConnectionString);

DataTable dt = new DataTable();

adapter.Fill(dt);

return dt;

}

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

{

if (e.CommandName == "Select")

{

GridDataItem dataItem = (GridDataItem)e.Item;

string strTxt = dataItem.GetDataKeyValue("DEALER_NUM").ToString();

string rowID = dataItem.GetDataKeyValue("ROW_ID").ToString();

Response.Redirect(

"/DealersFinanceApplication/Dealer/DealerDetails.aspx");

}

 

 

}

protected void Page_Init(object sender, System.EventArgs e)

{

DefineGridStructure();

}

 

private void DefineGridStructure()

{

bool isFromWindow = Convert.ToBoolean(Session["IsFromWindow"]);

//RadGrid grdDealerList = new RadGrid();

//grdDealerList.ID = "RadGrid1";

if (isFromWindow)

{

grdDealerList.DataSource =

"";

grdDealerList.Rebind();

}

grdDealerList.NeedDataSource +=

new GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource);

grdDealerList.ItemCommand +=

new GridCommandEventHandler(this.RadGrid1_ItemCommand);

//grdDealerList.DataSource = BindGrid();

grdDealerList.Skin =

"Inox";

//grdDealerList.Width = Unit.Percentage(100);

grdDealerList.PageSize = 5;

grdDealerList.AllowPaging =

true;

grdDealerList.PagerStyle.Mode =

GridPagerMode.NextPrevAndNumeric;

grdDealerList.AutoGenerateColumns =

false;

//grdDealerList.GroupingEnabled = true;

//grdDealerList.ShowGroupPanel = true;

grdDealerList.ShowStatusBar =

true;

grdDealerList.ClientSettings.AllowDragToGroup =

true;

grdDealerList.AllowSorting =

true;

grdDealerList.Width =

Unit.Percentage(100);

grdDealerList.ItemStyle.CssClass =

"RadGrid";

grdDealerList.MasterTableView.PageSize = 30;

grdDealerList.MasterTableView.DataKeyNames =

new string[] { "ROW_ID", "DEALER_NUM" };

GridButtonColumn selectColumn = new GridButtonColumn();

selectColumn.DataTextField =

"DEALER_NUM";

selectColumn.CommandArgument =

"DEALER_NUM";

selectColumn.CommandName =

"Select";

selectColumn.HeaderText =

"DealerNumber";

selectColumn.DataTextFormatString =

"<nobr>{0}</nobr>";

selectColumn.SortExpression =

"DEALER_NUM";

//selectColumn.

grdDealerList.MasterTableView.Columns.Add(selectColumn);

 

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(Request.MapPath(

"~/App_Data/DataMapping.xml"));

XmlNodeList columnNodeList = XML.GetNodeList("/DealerGrids/DealerGrid[@Name ='DealerList']/Columns/Column", xmlDoc);

 

foreach (XmlNode columnNode in columnNodeList)

{

string headerText = "";

headerText =

XML.GetAttributeValue("/Column", "DisplayText", columnNode.OuterXml);

if (headerText != null && headerText.Length > 0)

{

GridBoundColumn boundColumn = new GridBoundColumn();

boundColumn.DataField =

XML.GetAttributeValue("/Column", "TableColumnName", columnNode.OuterXml);

boundColumn.HeaderText = headerText;

boundColumn.DataFormatString =

"<nobr>{0}</nobr>";

grdDealerList.MasterTableView.Columns.Add(boundColumn);

}

}

this.PlaceHolder1.Controls.Add(grdDealerList);

if (isFromWindow)

{

grdDealerList.DataSource = BindGrid();

grdDealerList.Rebind();

}

Session[

"IsFromWindow"] = false;

}

 

//public readonly RadGrid DealerListGrid

//{

// get

// {

// return grdDealerList;

// }

//}

}

Page 2(Which i am displaying in radwindow)

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="DealersSearch.aspx.cs" Inherits="Dealer_DealersSearch" %>

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

 

<title><%=Resources.DealerFinance.DealerSearchHeader%></title>

 

<script language="javascript" type="text/javascript">

 

//This code is used to provide a reference to the radwindow "wrapper"

 

function GetRadWindow()

{

var oWindow = null;

if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog

 

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)

 

return oWindow;

}

function CloseOnReloadandReLoad()

{

RefreshParentPage();

//GetRadWindow().Close();

 

}

function CloseOnReload()

{

GetRadWindow().Close();

}

 

function RefreshParentPage()

{

GetRadWindow().BrowserWindow.location.reload();

}

function SelectAgency(code, name)

{

window.close();

window.opener.ParentFormPostBack(

'','');

window.opener.focus();

}

</script>

 

 

</

head>

<

body>

 

<form id="form1" runat="server">

 

<asp:Label ID="InjectScript" runat="server"></asp:Label>

 

<table>

 

<tr>

 

<td align="center" nowrap="nowrap" colspan="3" >

 

<div class="TitleTextNormal"> <%=Resources.DealerFinance.DealerSearchHeader%> </div>

 

</td>

 

</tr>

 

<tr>

 

<td height="10px" align="center" nowrap="nowrap" colspan="3" >

 

</td>

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.LegalName%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtLegalName" TabIndex="100" runat="server" MaxLength="30" size="30" ></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.DBAName%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtDBAName" TabIndex="101" runat="server" MaxLength="30" size="30"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.KawasakiName%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtKawasakiName" TabIndex="102" runat="server" MaxLength="30" size="30"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.Address%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtAddress" TabIndex="103" runat="server" MaxLength="30" size="30"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.City%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtCity" TabIndex="104" runat="server" MaxLength="30" size="20"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.State%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtState" TabIndex="105" runat="server" MaxLength="10" size="10"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.Zip%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtZip" TabIndex="106" runat="server" MaxLength="10" size="10"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.PrincipalLastName%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtPrincipalLastName" TabIndex="107" runat="server" MaxLength="30"

 

size="30"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.PrincipalSSN%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtPrincipalSSN" TabIndex="108" runat="server" MaxLength="10" size="10"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="right" nowrap="nowrap">

 

<%

=Resources.DealerFinance.DealerNumber%>

</td>

 

<td align="left">

 

<asp:TextBox ID="txtDealerNumber" TabIndex="109" runat="server" MaxLength="10" size="10"></asp:TextBox>

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

<tr>

 

<td align="center" colspan="2">

 

<br />

 

<!-- <asp:Button ID="btnSearch" runat="server" CausesValidation="false" OnClick="btnSearch_Click"

SkinID="DisplayButton" Text="Search" OnClientClick="SelectAgency()" /> -->

 

<asp:Button ID="Button1" runat="server" CausesValidation="false" OnClick="btnSearch_Click"

 

SkinID="DisplayButton" Text="Search" />

 

<asp:Button ID="btnCancel" runat="server" CausesValidation="false" OnClick="btnCancel_Click"

 

SkinID="DisplayButton" Text="Cancel" />

 

</td>

 

<td align="right" width="10px">

 

</td>

 

</tr>

 

</table>

 

</form>

</

body>

</

html>

code behind:

using

System;

using

System.Collections;

using

System.Configuration;

using

System.Data;

using

System.Linq;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.HtmlControls;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Xml.Linq;

using

Telerik.Web.UI;

public

partial class Dealer_DealersSearch : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

//Teleric

this.Page.DataBind();

}

protected void btnSearch_Click(object sender, EventArgs e)

{

DealSearchFields dealerSearchFileldsObj = new DealSearchFields();

dealerSearchFileldsObj.LegalName = txtLegalName.Text;

dealerSearchFileldsObj.DBAName = txtDBAName.Text;

dealerSearchFileldsObj.KawasakiName = txtKawasakiName.Text;

dealerSearchFileldsObj.Address = txtAddress.Text;

dealerSearchFileldsObj.City = txtCity.Text;

dealerSearchFileldsObj.State = txtState.Text;

dealerSearchFileldsObj.Zip = txtZip.Text;

dealerSearchFileldsObj.PrincipalLastName = txtPrincipalLastName.Text;

dealerSearchFileldsObj.PrincipalSSN = txtPrincipalSSN.Text;

dealerSearchFileldsObj.DealerNumber = txtDealerNumber.Text;

//

Session[

"DealerSearchFields"] = dealerSearchFileldsObj;

Session[

"IsFromWindow"] = true;

//Teleric

InjectScript.Text =

"<script>CloseOnReloadandReLoad()</" + "script>";

}

protected void btnCancel_Click(object sender, EventArgs e)

{

//Teleric

InjectScript.Text =

"<script>CloseOnReload()</" + "script>";

}

}

Master Page:

 

@ Master Language="C#" AutoEventWireup="true" CodeFile="DealerFinance.master.cs" Inherits="DealerFinance"

%>

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik"

%>

 

html xmlns

="http://www.w3.org/1999/xhtml">

head runat

="server">

 

<title>Untitled Page</title

>

 

<link href="App_Themes/DealerFinance/DealerFinance.css" rel="Stylesheet" type="text/css"

/>

 

<link href="JavaScript/DealerFinance.js" type="text/javascript"

/>

 

<asp:ContentPlaceHolder ID="head" runat

="server">

 

</asp:ContentPlaceHolder

>

head

>

body

>

 

<form id="form1" runat

="server">

 

<telerik:RadScriptManager ID="RadScriptManager1" runat

="server">

 

</telerik:RadScriptManager

>

 

<table

>

 

<tr

>

 

<td

>

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" BorderColor

="Silver">

 

<telerik:RadTabStrip ID="rtsDealerMenu" runat="server" Skin="Web20" SelectedIndex

="0">

 

</telerik:RadTabStrip

>

 

</telerik:RadAjaxPanel

>

 

</td

>

 

</tr

>

 

<tr

>

 

<td

>

 

<asp:ContentPlaceHolder ID="DealerFinancePlaceHolder" runat

="server">

 

</asp:ContentPlaceHolder

>

 

</td

>

 

</tr

>

 

</table

>

 

</form

>

body

>

html

>

Master Page Code behind :

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 15 Sep 2008, 10:35 AM
Hello Sudipta,

Based on the supplied information, it is hard to determine what may be causing the erroneous behavior. If the problem persists at your end, you can open a formal support ticket, and send us a small working project, demonstrating the problem. We will review it locally, and get back to you with additional information.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Sudipta Burman
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or