Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 20th, 2006, 05:15 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to cmedllo@tams.com
Default selectedvalue dynamic edititemtemplate ascx

I have a dropdownlist in a usercontrol.
I dynamically load the control in a datagrid.
the itemtemplate is just a label of value from dataset for the datagrid
clicking on edit does display the ascx control dropdown with all the values

from the binddata method inside ascx. In the aspx file I can get the value I

am looking for from the datagrid underlying dataset but how and when am I

getting this to the ascx control?

//aspx file

TemplateColumn tcl5 = new TemplateColumn();
ITemplate temp= Page.LoadTemplate("Controls/StoreSelector.ascx");
tcl5.EditItemTemplate = temp;
dgRt2.Columns.Add(tcl5);


private void dgRt2_ItemDataBound(object sender, DataGridItemEventArgs e)
{
    DataGrid dg = (DataGrid)sender;
    int cnt = e.Item.ItemIndex + (dg.PageSize * dg.CurrentPageIndex);
    DataTable dtBound = (DataTable)dg.DataSource;

//from the dt get the value I want to select
    string strZone = dtBound.Rows[cnt]["zonelu"].ToString();
//I try to cast the dropdown in the grid so I can set the selected value
    SISWebAdmin.Controls.StoreSelector ddlz =

(SISWebAdmin.Controls.StoreSelector)e.Item.Cells[0].FindControl("storeList");
                ddlz.SelectedValue = strZone;

//ascx file
// I have a public property SelectedValue
public string SelectedValue
{
    get{return storeList.SelectedValue;}
    set{storeList.SelectedValue = value;}
}

// problem maybe that in the ascx file in page load I cannot check for post

back because the list is only loaded on the postback but the error I get is

e1 at SISWebAdmin.WebForm1.dgRt2_ItemDataBound(Object sender,

DataGridItemEventArgs e) in c:\program files\common files\microsoft shared\web

server extensions\60\template\layouts\siswebadmin\webform 1.aspx.cs:line 804 at

System.Web.UI.WebControls.DataGrid.OnItemDataBound (DataGridItemEventArgs e) at

System.Web.UI.WebControls.DataGrid.CreateItem(Int3 2 itemIndex, Int32

dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,

DataGridColumn[] columns, TableRowCollection rows, PagedDataSource

pagedDataSource) at

System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean

useDataSource) at

System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) at

System.Web.UI.WebControls.BaseDataList.DataBind() at

SISWebAdmin.WebForm1.fillgrid(String sFullname, String strZone, String strArea,

String strTitle) in c:\program files\common files\microsoft shared\web server

extensions\60\template\layouts\siswebadmin\webform 1.aspx.cs:line 368Object

reference not set to an instance of an object.SISWebAdmin

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get SelectedValue of Control obrienkev C# 2005 3 November 8th, 2007 12:17 PM
Need Help with DropDownList SelectedValue putputty ASP.NET 2.0 Basics 4 June 27th, 2007 11:44 AM
Datalist-edititemtemplate-RadioButtonList cp75 ASP.NET 1.0 and 1.1 Basics 1 September 1st, 2006 12:56 PM
comboBox.SelectedValue melvik C# 1 August 19th, 2003 09:21 AM



All times are GMT -4. The time now is 03:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.