Click here to Skip to main content
15,912,400 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Example ASP.NET AJAX Pin
Not Active14-Feb-10 10:39
mentorNot Active14-Feb-10 10:39 
GeneralRe: Example ASP.NET AJAX Pin
Keith Barrow15-Feb-10 1:11
professionalKeith Barrow15-Feb-10 1:11 
Questionresolve Url and catch Query String [Solved] Pin
kasraa0009800013-Feb-10 6:00
kasraa0009800013-Feb-10 6:00 
AnswerRe: resolve Url and catch Query String Pin
Anurag Gandhi13-Feb-10 6:37
professionalAnurag Gandhi13-Feb-10 6:37 
AnswerRe: resolve Url and catch Query String Pin
Not Active13-Feb-10 7:28
mentorNot Active13-Feb-10 7:28 
AnswerRe: resolve Url and catch Query String Pin
Hesham Amin13-Feb-10 7:33
Hesham Amin13-Feb-10 7:33 
GeneralRe: resolve Url and catch Query String Pin
kasraa0009800013-Feb-10 12:32
kasraa0009800013-Feb-10 12:32 
QuestionProblem with GridView [modified] Pin
Sider8913-Feb-10 4:04
Sider8913-Feb-10 4:04 
<asp:EntityDataSource ID="srcCity" runat="server" ContextTypeName="Namespace.Core.Tracking.Domain" EntitySetName="Cities"
EntityTypeFilter="City" Include="Country" AutoGenerateWhereClause="true"/>
       <WhereParameters/>
        <asp:QueryStringParameter Name="Country.ID" Type="Int32"
             QueryStringField="CountryID" />
     </WhereParameters>
</asp:EntityDataSource>

<asp:EntityDataSource ID="srcCountry" runat="server" ContextTypeName="Namespace.Core.Tracking.Domain" 
EntitySetName="Countries" EntityTypeFilter="Country" OrderBy="it.Name"/>


<asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="srcCity">
   <MasterTableView DataSourceID="srcCity" EditMode="InPlace">
      <asp:TemplateField>
            <asp:Label ID="lblName" runat="server" 
                Text='<%# Eval("Country.Name") %>'/>
       </asp:TemplateField>
      <EditItemTemplate>
           <asp:DropDownList ID="lstCountry" runat="server" 
                SelectedValue='<%# Eval("ID") %>'DataSourceID="srcCountry"
                DataTextField="Name" DataValueField="ID"       
                AppendDataBoundItems="true">
                <ListItems>
                    <asp:ListItem Text="" Value="" />
                </ListItems>
           </DropDownList>
      </EditItemTemplate>
  </MasterTableView>
</GridView>


public partial class City : System.Web.UI.Page{
 
   protected void Page_Load(object sender, EventArgs e){
       grid.RowCreated += new GridViewRowEventHandler(grid_RowCreated);
   }

    void grid_RowCreated(object sender, GridViewRowEventArgs e){

       if (e.Row.DataItem != null){
           var city = EntityDataSourceExtensions.GetItemObject<City>(e.Row.DataItem);
       if(city.Country != null) 
          (grid.FindControl("lstCountry")as DropDownList).SelectedValue = city.Country.ID.ToString(); <-- Here I got Exception
      /*
      System.NullReferenceException was unhandled by user code
      Message=Object reference not set to an instance of an object.
      what the problem? I think object casting is true */
         }
    }
}



public static class EntityDataSourceExtensions {

	public static TEntity GetItemObject<TEntity>(object dataItem) where TEntity : class {

		var entity = dataItem as TEntity;

		if(entity != null) 
                    return entity;

		var td = dataItem as System.ComponentModel.ICustomTypeDescriptor;

		if(td != null)
                     return (TEntity)td.GetPropertyOwner(null);


		return null;
	}
}



C# Developer
-- Modified Sunday, February 14, 2010 3:22 AM
modified on Sunday, February 14, 2010 3:39 AM

AnswerRe: Problem with GridView Pin
Anurag Gandhi13-Feb-10 6:31
professionalAnurag Gandhi13-Feb-10 6:31 
AnswerRe: Problem with GridView Pin
Sider8914-Feb-10 2:57
Sider8914-Feb-10 2:57 
Questionproblem with uploading/downloading .docx file Pin
shankbond13-Feb-10 3:18
shankbond13-Feb-10 3:18 
AnswerRe: problem with uploading/downloading .docx file Pin
Hesham Amin13-Feb-10 7:40
Hesham Amin13-Feb-10 7:40 
GeneralRe: problem with uploading/downloading .docx file Pin
shankbond13-Feb-10 23:13
shankbond13-Feb-10 23:13 
Questionvedio confernce in asp.net Pin
harilatha12-Feb-10 19:45
harilatha12-Feb-10 19:45 
AnswerRe: vedio confernce in asp.net Pin
Abhijit Jana12-Feb-10 20:13
professionalAbhijit Jana12-Feb-10 20:13 
GeneralRe: vedio confernce in asp.net Pin
harilatha12-Feb-10 20:28
harilatha12-Feb-10 20:28 
GeneralRe: vedio confernce in asp.net Pin
sashidhar12-Feb-10 22:05
sashidhar12-Feb-10 22:05 
Questiondesigner appear empty after change source of page Pin
kasraa0009800012-Feb-10 9:58
kasraa0009800012-Feb-10 9:58 
AnswerRe: designer appear empty after change source of page Pin
keyur satyadev12-Feb-10 18:57
keyur satyadev12-Feb-10 18:57 
QuestionRe: designer appear empty after change source of page Pin
kasraa0009800013-Feb-10 5:37
kasraa0009800013-Feb-10 5:37 
Questioniframe pop working in IE but not in FireFox Pin
kamran pervaiz12-Feb-10 1:47
kamran pervaiz12-Feb-10 1:47 
AnswerRe: iframe pop working in IE but not in FireFox Pin
T M Gray12-Feb-10 5:14
T M Gray12-Feb-10 5:14 
QuestionClickheat Clickmap? Pin
emiliovillarox12-Feb-10 0:18
emiliovillarox12-Feb-10 0:18 
QuestionIIS problem in asp.net Pin
JC.KaNNaN12-Feb-10 0:00
JC.KaNNaN12-Feb-10 0:00 
AnswerRe: IIS problem in asp.net Pin
Abhijit Jana12-Feb-10 1:54
professionalAbhijit Jana12-Feb-10 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.