Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a datagrid, have 5 text fields displayed on it.

 

If I'm in ModeA, i want the first Col to have , for example, "Company".

 

If I'm in ModeB, I want the first Col to have, for example, "Contact"...

 

so depending on the mode, I want to change one or 2 text fields ...

 

I can have a panel and just display the right panel for the right mode..but was wondering if there's another way of changing the textfield without using panels...

Posted (edited)

This is what I want:

 

Mode1:

 

Company

Address

...

 

Mode2:

Contact

Address

....

 

So, display a totally different header in Mode2, update a different field ...Dont want to put this in a panel just because only 2 fields are different from Mode1 and Mode2..

 

This is what I have:

[b]<ItemTemplate>[/b]
<table border="0">
<tr>
	<td align="left"><b>[b]Company:[/b]</b></td>
	<td>
	 <%# Container.DataItem("cmp_name1") %>
	 </td>
</tr>
<tr>
	<td align="left"><b>[b]Address:[/b]</b></td>
	<td>
	 <%# Container.DataItem("cmp_account") %>
 </td>
</tr>
</table>
[b]</itemtemplate>[/b]
[b]<EditItemTemplate>[/b]
<table border="0">
<tr>
 <td align="left"><b>[b]Company:[/b]</b></td>
 <td>
	 <%# Container.DataItem("cmm_name1") %>
 </td>
 </tr>
<tr>
 <td align="left"><b>[b]Address:[/b]</b></td>
 <td>
	 <%# Container.DataItem("addr") %>
 </td>
</tr>
....

[edit]Removed tabs:Robby[/edit]

Edited by Robby
Posted
Whats driving the switching between Company and Contact? QueryString param? something in the DB ?
If you make it idiot proof, they'll build a better idiot :-)
Posted

Yes, something in the DB. When the user logs in, the choose either Mode1 or Mode2...

 

The "Mode" that I keep in a session variable decides what to display...

 

But not sure how to do it in a datagrid..as I've shown below...

 

Any help to get me going would be great..thanks..

Posted

In the Front:

Switch to something like inside the Template:

<td align="left"><b><asp:literal id="txtLabel" runat="server"/></b></td>

 

Also add a not-visible BoundColumnwith whatever is the witch

<asp:BoundColumn visible="false" DataField="SwitchValue"/>

 

In Code:

Use the "OnItemDataBound" event... and you can change the text of the Literal Control based on the value of the BoundColumn

If you make it idiot proof, they'll build a better idiot :-)
Posted

Hmm, couldnt find good examples of what u described..I tried this site:

 

http://aspnet.4guysfromrolla.com/articles/020503-1.aspx

 

I'm using a template.., I think i need to break that template and add a "boundcolumn" ...but then wasnt sure how to do the databinding to the database...

 

so I did this I've seen it in an ASP page...wonder if it's ok to do this in ASP.Net..it does display the info correctly...

 

<tr>[b] <% if session("Mode") = "22" then %>[/b]
   <td align="left"><b>Company:</b></td>
   <td>
<%# Container.DataItem("cmp") %>
   </td>
[b]<%else%>[/b]
   <td align="left"><b>Contact:</b></td>
   <td>
<%# Container.DataItem("contact") %>
   </td>
[/b]<%end if %>[/b]

</tr>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...