|
*grin* probably because it wasn't there and you put more time in to your reply.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
myinstincts wrote: SqlCommand cmd = new SqlCommand("select place_name from place inner join state on place.state_id=state.state_id where state_name ='" + statedpdwnlist.SelectedItem.Value + "'", con);
Do like this :
string S="select place_name from place inner join state on place.state_id=state.state_id where state_name ='" + statedpdwnlist.SelectedItem.Value + "'"
SqlCommand cmd = new SqlCommand(s, con);
Now, Put a breakpoint on String S line, check the value of S. Then put the same string on SQL Server Query window and check the result. This will clear your doubts !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hi,
I have hosted an application of ASP.NET 2.0 on my windows 2003 Server in wwwroot folder. During execuation application try to load some pdf from a directory and create document in it. "Document"
Application ASP.NET pages are working very much fine.
www.Myapplication.com/myfirstpage.aspx
but when i clicked on
link to open the PDF file in popup i expected to get this url on client machine browser.
http://www.MyApplication.com/documents/ABC123.pdf
but instead of above link it cusing problem and using following address
http://localhost/document/ABC123.pdf
I have ONLY Build (no Code). I have done this before as i was encoutered this situation before but i dont know i resolved that in past.
actually I was chaning some rights on different user like IIS_WPG and everyone?
Please give you thoughts and ideas about this issue,
Thanks,
Waleed
Waleed Butt, Software Engineer
Extended Innovation, Netsol
Tel: +92 (42) 111 44 88 00 | Fax: +92 (42) 570 1059 | Mobile: +92 (300) 4496414
E-Mail: buttw@extendedinnovation.com | Web: www.extendedinnovation.com
|
|
|
|
|
Hello,
This is my first time submitting a question ANYWHERE, please be kind to the noobie.
Situation:
• Creating a NOTING System for indivisual users
• Notes are stored in DB and retrieved for display on the web application
• Notes are grouped by Date entered
• Since notes can be lengthy an abbreviated notes is displayed
• A hover control is created to "show" the full note for reference/editing and deletion
• Nested Parent to Child controls are as follows
> PlaceHolder [ph_your_note] (static created on aspx presentation layer)
--- ALL dynamic cotrols are placed here ---
> pnl_main (created to house nested controls in one panel
> pnl_date (created to hold all notes of one date value)
> hvm_note ( hover control to show the sub panel that displays the full note)
> pnl_sub (created to hold the note header, textbox, update and delete image buttons )
> tb (text box that will be used to Display/Edit returned value of the
full note written to the database)
THIS IS THE CONTROL I AM LOOKING TO RETRIEVE THE VALUE FROM
What I currently know:
• The dynamically created Update Image Button is where I am trying to retrieve the tb.Text value (shown in code snippet below)
• I have located the value of the text box here, through QuickWatch
((System.Web.UI.WebControls.TextBox)(((System.Web.UI.WebControls.PlaceHolder)pnl_your_note.Controls._controls[0]).Controls[23].Controls[1].Controls[0].Controls[1])).Text
>Controls[23] is the varible that I need to determine how to dynamically call
Code snippets:
public void BindNotes()
{
DataSet ds = Execute_Notes();
string check_date = "";
string hold_date = "";
ph_your_note.Controls.Clear();
Panel pnl_main = new Panel();
pnl_main.ID = "pnl_notes_main";
int i = 0;
while (i < ds.Tables[0].Rows.Count)
{
HiddenField hf = new HiddenField();
hf.Value = ds.Tables[0].Rows[i]["Note_ID"].ToString();
notes_id = hf.Value.ToString();
Panel pnl_date = new Panel();
pnl_date.Attributes.Add("runat", "server");
pnl_date.ID = "pnl_date_" + hf.Value.ToString();
Panel pnl_sub = new Panel();
pnl_sub.Attributes.Add("runat", "server");
pnl_sub.ID = "pnl_sub_" + hf.Value.ToString();
pnl_sub.BorderWidth = Unit.Pixel(1);
pnl_sub.BorderStyle = BorderStyle.Solid;
pnl_sub.BorderColor = System.Drawing.ColorTranslator.FromHtml("black");
Label lbl_abbreviated = new Label();
lbl_abbreviated.Attributes.Add("runat", "server");
lbl_abbreviated.ID = "lbl_abbreviated" + hf.Value.ToString();
lbl_abbreviated.CssClass = "note_abreviated";
Label lbl_date = new Label();
lbl_date.Attributes.Add("runat", "server");
Label lbl_br = new Label();
lbl_br.Attributes.Add("runat", "server");
lbl_br.Text = "<br>";
Label lbl_edit = new Label();
lbl_edit.Attributes.Add("runat", "server");
lbl_edit.Text = "<center>view - update - remove <br></center>";
Label lbl_spacer = new Label();
lbl_spacer.Attributes.Add("runat", "server");
lbl_spacer.Text = " ";
if (ds.Tables[0].Rows[i]["Note"].ToString().Length > 22)
{
lbl_abbreviated.Text = " <img id='img_show' src='images/btn_icons/note_edit_16x.png' height='11px' /> " + ds.Tables[0].Rows[i]["Note"].ToString().Substring(0, 22) + ". . .";
}
else
{
lbl_abbreviated.Text = " <img id='img_show' src='images/btn_icons/note_edit_16x.png' height='11px' /> " + ds.Tables[0].Rows[i]["Note"].ToString();
}
check_date = Convert.ToDateTime(ds.Tables[0].Rows[i]["DATE_ENTERED"]).ToString("MMMM d, yyyy");
if (check_date != hold_date)
{
lbl_date.Text = " " + check_date.ToString() + "<br>";
lbl_date.CssClass = "note_date_seperator";
pnl_date.Controls.Add(lbl_date);
}
TextBox tb = new TextBox();
tb.Attributes.Add("runat", "server");
tb.TextMode = TextBoxMode.MultiLine;
tb.Width = Unit.Pixel(175);
tb.Height = Unit.Pixel(150);
tb.Text = ds.Tables[0].Rows[i]["Note"].ToString();
tb.ID = "tb_note_" + hf.Value.ToString();
tb.CssClass = "note_tb_format";
ImageButton img_btn_update_edit = new ImageButton();
img_btn_update_edit.Click += new ImageClickEventHandler(img_btn_update_note_Click);
img_btn_update_edit.ImageUrl = "images/btn_icons/note_accept_16x.png";
img_btn_update_edit.Attributes.Add("runat", "server");
img_btn_update_edit.ID = "note_" + hf.Value.ToString();
img_btn_update_edit.CssClass = "note_panel_icons";
img_btn_update_edit.ToolTip = hf.Value.ToString();
AttributeCollection note = img_btn_update_edit.Attributes;
ImageButton img_btn_remove = new ImageButton();
img_btn_remove.ImageUrl = "images/btn_icons/note_remove_16x.png";
img_btn_remove.CssClass = "note_panel_icons";
HoverMenuExtender hvm_note = new HoverMenuExtender();
hvm_note.TargetControlID += lbl_abbreviated.ID.ToString();
hvm_note.PopupControlID += pnl_sub.ID.ToString();
hvm_note.ID = "hvm_note_" + hf.Value.ToString();
hvm_note.OffsetX = 20;
hvm_note.PopDelay = 500;
pnl_date.Controls.Add(lbl_abbreviated);
pnl_date.Controls.Add(hvm_note);
pnl_sub.Controls.Add(lbl_edit);
pnl_sub.Controls.Add(tb);
pnl_sub.Controls.Add(lbl_br);
pnl_sub.Controls.Add(img_btn_update_edit);
pnl_sub.Controls.Add(img_btn_remove);
pnl_sub.CssClass = "note_sub_panel";
hvm_note.Controls.Add(pnl_sub);
ph_your_note.Controls.Add(pnl_date);
hold_date = check_date;
i++;
}
ph_your_note.Controls.Add(pnl_main);
}
protected void img_btn_update_note_Click(object sender, ImageClickEventArgs e)
{
notes_cmd = "update";
string ctrl_name = "tb_note_" + notes_id.ToString();
if (ctrl_name != String.Empty)
{
}
else
{
lbl_create_note.Text = "failed";
}
BindNotes();
}
A screen shot can be provided for viual eference if needed.
Thanks to anyone who can guide me to the answer.
Steve Crochet
Senior Application Developer
Ticketmaster
(and no I can't, I don't even get free tickets)
|
|
|
|
|
Steve Crochet wrote: string ctrl_name = "tb_note_" + notes_id.ToString();
so, ctrl_name can't EVER equal string.empty. Do you mean if notes_id.ToString is an empty string ? Where does notes_id come from ? Could it be null ?
Wait, this is not a web question. I would create a map that maps the notes_id itself to the control, so you can just look up the control, using the info you have at hand.
ARGH !! It IS a web question. I am confused. Yes, use FindControl to find the control.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian
• You are right about the ctrl_name, that was an attempt in the wrong direction.
• notes_id is never null, it is the UID from the database pertaining to that particular note
• I have tried the FindControl, but I am very UNclear on how to find that control 5 controls deep.
•• I have also made unique Ids for each control with the control name appended by the note_id
ex: pnl_sub_53
tb_53
hvm_note_53
(53 = note_id)
not sure why this is not a web question, and to your comment on mapping the note_id to the control, I assume that is what I am doing on the ID section (above ••).
one thing that I have noticed that the control elements are not visible to the img_btn_update_note_Click event How can I make them accessible to any or all CLICK events?
Steve
|
|
|
|
|
Steve Crochet wrote: I have tried the FindControl, but I am very UNclear on how to find that control 5 controls deep.
If FindControl does not work, perhaps you need to find the control at each level as you work your way down ?
Steve Crochet wrote: not sure why this is not a web question
I just read your C# part and suddenly thought I was in the C# forum. My bad, sorry.
Steve Crochet wrote: and to your comment on mapping the note_id to the control,
I meant building a map in memory, but that won't work, because you don't have any state.
Steve Crochet wrote: one thing that I have noticed that the control elements are not visible to the img_btn_update_note_Click event How can I make them accessible to any or all CLICK events?
How do you mean, not visible ? What elements are we talking about ?
Ultimately, you can iterate through the controls collection looking for controls if you know where they are.
I just looked at your code again. You call BindNotes ( which adds the control ) AFTER the code that's supposed to work with the control. If you're having to add the controls again in the same method, why not just pass the id you're looking for into that method and deal with it as you add it ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have a gridview with an update capabilities - a textbox column (roomName), a dropdownlist(orgID), a dropdownlist(roomTypeID),a checkbox column (dialOut), a checkbox column (dialIn). When I try to add another checkbox column, the sql database isn't updated properly with a 0/1 or false/true but with null. I've tried everything I can think of. Can anyone help?
<asp:CommandField ShowEditButton="True" ValidationGroup="valGrp" CancelText="Cxl" EditText="Edit" UpdateText="Upd" />
<asp:BoundField DataField="roomID" />
<asp:TemplateField HeaderText="RoomName">
<EditItemTemplate>
<asp:TextBox ID="txtRoom" Columns="10" runat="server" SkinID="txtSm" Text='<%# Bind("roomname") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblRoom" runat="server" Text='<%# Bind("roomName") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnAdd" runat="server" skinID="btnGo" Text="Add" CommandName="Insert" />
<asp:TextBox ID="txtRoomAdd" Columns="10" runat="server" SkinID="txtSm" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Org">
<EditItemTemplate>
<asp:DropDownList ID="orgDDL" runat="server" SkinID="ddl" DataSourceID="orgDS"
DataTextField="org" DataValueField="orgID" SelectedValue='<%# Bind("orgID") %>'>
</asp:DropDownList><asp:SqlDataSource ID="orgDS" runat="server" ConnectionString="<%$ ConnectionStrings:Str %>"
SelectCommand="select statement"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblOrg" runat="server" Text='<%# Bind("org") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="orgDDLAdd" runat="server" SkinID="ddl" DataSourceID="orgAddDS2"
DataTextField="org" DataValueField="orgID">
</asp:DropDownList><asp:SqlDataSource ID="orgAddDS2" runat="server" ConnectionString="<%$ ConnectionStrings:Str %>"
SelectCommand="select statement">
</asp:SqlDataSource>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<EditItemTemplate>
<asp:DropDownList ID="typeDDL" runat="server" SkinID="ddl" DataSourceID="typeDS"
DataTextField="roomType" DataValueField="roomTypeID" SelectedValue='<%# Bind("roomTypeID") %>'>
</asp:DropDownList><asp:SqlDataSource ID="typeDS" runat="server" ConnectionString="<%$ ConnectionStrings:Str %>"
SelectCommand="select statement">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblroomType" runat="server" Text='<%# Bind("roomType") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="typeDDLAdd" runat="server" SkinID="ddl" DataSourceID="addDS3"
DataTextField="roomType" DataValueField="roomTypeID">
</asp:DropDownList><asp:SqlDataSource ID="addDS3" runat="server" ConnectionString="<%$ ConnectionStrings:Str %>"
SelectCommand="select statement">
</asp:SqlDataSource>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DialOut">
<EditItemTemplate><asp:CheckBox ID="chkOutEdit" runat="server" checked='<%# Bind("dialOut") %>' /></EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkOut" runat="server" checked='<%# Bind("dialOut") %>' Enabled="false" /></ItemTemplate>
<FooterTemplate><asp:CheckBox ID="chkOutAdd" runat="server" /></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DialIn">
<EditItemTemplate><asp:CheckBox ID="chkInEdit" runat="server" checked='<%# Bind("dialIn") %>' /></EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkIn" runat="server" checked='<%# Bind("dialIn") %>' Enabled="false" /></ItemTemplate>
<FooterTemplate><asp:CheckBox ID="chkInAdd" runat="server" /></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Webinar">
<EditItemTemplate><asp:CheckBox ID="chkWebEdit" runat="server" checked='<%# Bind("webinarCapable") %>' /></EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkWeb" runat="server" checked='<%# Bind("webinarCapable") %>' Enabled="false" /></ItemTemplate>
<FooterTemplate><asp:CheckBox ID="chkWebAdd" runat="server" /></FooterTemplate>
</asp:TemplateField>
Update stuff:
UpdateCommand="update myTable set roomname=@roomName, orgID=@orgID, roomTypeID=@roomTypeID, dialOut=@dialout, dialIn=@dialin, webinarCapable=@web where roomID = @roomID"
>
<UpdateParameters>
<asp:Parameter Name="roomName" Type="String" />
<asp:Parameter Name="orgID" Type="Int32" />
<asp:Parameter Name="roomTypeID" Type="Int32" />
<asp:Parameter Name="dialout" Type="Byte" />
<asp:Parameter Name="dialin" Type="Byte" />
<asp:Parameter Name="web" Type="Byte" />
</UpdateParameters>
TABLE [dbo].[myTable](
[roomID] [int] IDENTITY(1,1) NOT NULL,
[roomName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[orgID] [int] NULL,
[roomTypeID] [int] NULL,
[dialOut] [bit] NULL CONSTRAINT [DF_xTblRoom_dialOut] DEFAULT ((0)),
[dialIn] [bit] NULL CONSTRAINT [DF_xTblRoom_dialIn] DEFAULT ((0)),
[webinarCapable] [bit] NULL CONSTRAINT [DF_xTblRoom_webinarCapable] DEFAULT ((0))
|
|
|
|
|
Not sure what I did wrong, still, but I deleted the aspx page and started over from scratch. Everything works fine now..... Scratchin' my head hard!
|
|
|
|
|
Hi,
We are building an ASP.NET page and in that we need place a Scrollable Panel containing a ListView.
The ListView in-turn will hold different records, which are retrieved from Database.
Could anyone please refer a code sample for this?
Thanks and Regards.
|
|
|
|
|
Place the ListView in a div and apply the CSS property overflow:scroll to it.
only two letters away from being an asset
|
|
|
|
|
concatenated three dropdownlists values i inserted year month day into a column in sql table.
how to retrieve that values seperately to that three ddls from sql table
help plz...
for inserting i used....
string str = DropDownList5.SelectedItem.Value.ToString();
string str1 = DropDownList6.SelectedItem.Value.ToString();
string str2 = DropDownList7.SelectedItem.Value.ToString();
string final = str1 + "-" + str + "-" + str2;
cmd.Parameters.Add("@startdate", SqlDbType.SmallDateTime.ToString()).Value = final;
|
|
|
|
|
madhukk wrote: cmd.Parameters.Add("@startdate", SqlDbType.SmallDateTime.ToString()).Value = final;
Try This .
DateTime MyDateTime;
MyDateTime = new DateTime();
MyDateTime = DateTime.ParseExact(final , "yyyy-MM-dd",
null);
cmd.Parameters.Add("@startdate",MyDateTime );
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
im able to insert it..
i want to retrieve startdate column and transfer to other page using session..
using datareader i stored that column in a string
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{ Session["startdate"] = dr["startdate"];
}
in next page to tranfer the value
if i write this
DropDownList1.SelectedItem.Text= Session["startdate"].ToString();
im getting complete date(10/20/2001) in DropDownList1..
but what i want is ddl1(10) ddl2(20) ddl3(2001) as i inserted...
|
|
|
|
|
madhukk wrote: im getting complete date(10/20/2001) in DropDownList1..
Which is exactly what you coded. If you want to separate the values across different drop downs then you need to separate the components of the date. Day to one, month to another, and year to the third. How complicated can this be?
|
|
|
|
|
You need to split them before store.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
thats what im unable to any sample code please..
|
|
|
|
|
madhukk wrote: any sample code please..
One sample code for you.
String DateText="12/10/2009";
String [] DatePart= DateText.Split('/');
string dd=DatePart[0].ToString();
string mm=DatePart[1].ToString();
string yy=DatePart[2].ToString();
Hope you can take it forward. Let me know if any more issue.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I would prefer this one as it does not believe on string manipulatio and when we have datetime datatype then why do string manipulation?
String strDate = "12/27/2009";
String strFormat = "mm/dd/yyyy";
System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;
DateTime dt = DateTime.ParseExact(strDate, strFormat, provider);
String dd = dt.Day.ToString();
String mm = dt.Month.ToString();
String yyyy = dt.Year.ToString();
|
|
|
|
|
Yes Nish, You are Correct. Actually there are many ways that we can implement it. I have given a very basic example. You given much better!
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
If everybody stored their datetime values properly as DateTime values and not as strings they would not get into this mess. Who is teaching all these awful habits?
|
|
|
|
|
Session["headline"] = dr["headline"];
Session["startdate"] = dr["startdate"];
Response.Redirect("newsedit.aspx");
next page
TextBox5.Text = Session["headline"].ToString();
String DateText = Session["startdate"].ToString();
String[] DatePart = DateText.Split('/');
string dd = DatePart[0].ToString();
string mm = DatePart[1].ToString();
string yy = DatePart[2].ToString();
DropDownList6.SelectedItem.Text=dd.ToString();
Object reference not set to an instance of an object.
|
|
|
|
|
madhukk wrote: Session["headline"] = dr["headline"];
Session["startdate"] = dr["startdate"];
Response.Redirect("newsedit.aspx");
next page
TextBox5.Text = Session["headline"].ToString();
String DateText = Session["startdate"].ToString();
String[] DatePart = DateText.Split('/');
string dd = DatePart[0].ToString();
string mm = DatePart[1].ToString();
string yy = DatePart[2].ToString();
DropDownList6.SelectedItem.Text=dd.ToString();
Object reference not set to an instance of an object.
What is ur question ?
madhukk wrote: DropDownList6.SelectedItem.Text=dd.ToString();
Object reference not set to an instance of an object.
I guess this one.
What is the value of dd.ToString(); ? Does this exist on the dropdownlist? Hope now you understand what I want to mean
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
SELECT DAY(startDate) as day, MONTH(startDate) as month, YEAR(startDate) AS Year FROM YourTable
|
|
|
|
|
J4amieC wrote: SELECT DAY(startDate) as day, MONTH(startDate) as month, YEAR(startDate) AS Year FROM YourTable
No, no, no! That's MUCH too sensible ...
|
|
|
|