|
learningman wrote: Can someone guide me????
Well, as Yusuf said, the message is self explanatory. You have something that is a string (nvarchar) that you are treating as binary (varbinary) in SQL Server. SQL Server can't do that implicity. You have to be explicity and tell it how you want the information converted (or just confirm that you do really want it converted and it isn't an error in your code)
Since you've not shown the SQL code (this is a SQL Exception after all) we can't guide you into the portion that may be causing the error.
|
|
|
|
|
I have three ListBox on a page. Select a few items from ListBox1 and then click a button, the selected items are added to ListBox2 and ListBox3. Here is the interesting behavior I observed. See the code below. After the first loop, items are added to ListBox2. I de-select the added items in ListBox2 (ListBox2.SelectedIndex=-1). This statement not only de-select items in ListBox2 but also causes the loss of selections in ListBox1. As a result, the second loop does not add anything to ListBox3. If this statement is commented out, the second loop add all selected items from ListBox1 to ListBox3. Does anyone know why this is happening? Is this a designed behavior? How to workaround this? Thanks,
foreach(ListItem itm in ListBox1.Items)
{
if (itm.Selected)
{
ListBox2.Items.Add(itm);
}
}
ListBox2.SelectedIndex = -1; //This line makes difference
foreach (ListItem itm in ListBox1.Items)
{
if (itm.Selected)
{
ListBox3.Items.Add(itm);
}
}
TOMZ_KV
|
|
|
|
|
hi..
Try out this..
foreach (ListItem itm in ListBox1.Items)
{
if (itm.Selected)
{
ListBox2.Items.Add(itm);
}
}
foreach (ListItem itm in ListBox1.Items)
{
if (itm.Selected)
{
ListBox3.Items.Add(itm);
}
}
ListBox2.SelectedIndex = -1;
And following will be the best option according to me:
foreach (ListItem itm in ListBox1.Items)
{
if (itm.Selected)
{
ListBox2.Items.Add(itm);
ListBox3.Items.Add(itm);
}
}
ListBox2.SelectedIndex = -1;
Thanks..
|
|
|
|
|
Thanks for your reply. Your solution definitely work. However, I placed one loop into a class to reuse it for all list controls like the following:
public void MoveListItem(ListControl Box1, ListControl Box2)
{
foreach (ListItem itm in Box1.Items)
{
if (itm.Selected)
{
Box2.Items.Add(itm);
}
}
Box2.SelectedIndex = -1;
}
I then call the method:
MoveListItem(ListBox1, ListBox2);
MoveListItem(ListBox1, ListBox3);
I guess the possible workaround could be to remove the de-selection statement Box2.SelectedIndex=-1 from the method and use it outside of the method:
MoveListItem(ListBox1, ListBox2);
ListBox2.SelectedIndex = -1;
MoveListItem(ListBox1, ListBox3);
ListBox3.SelectedIndex = -1;
Another possible way is to place ListItemCollection in the mehod to hold the selected items from Box1. After adding items to Box2, re-select the items in Box1. In this case, no de-selection is needed outside of the method call.
These are all workarounds. I still think the Box1 should not lose its selection when Box2 selection is cleared.
Thanks,
TOMZ_KV
|
|
|
|
|
The issue was resolved. It is object reference that results in this behavior. When adding to ListBox2, create a new ListItem object to avoid the object reference between ListBox1 and ListBox1 like that following
ListBox2.Items.Add(new ListItem(itm.Text, itm.Value);
instead of
ListBox1.Items.Add(itm);
TOMZ_KV
|
|
|
|
|
When I bring in a Report Viewer to my web form in crystal 11.5.37 it automatically adds references to 11.5.33 as well as 11.5.37 giving me duplicate references errors. If I delete the 11.5.33 references, it keeps recreating them when I build the web site. How can I permanently destroy them?
|
|
|
|
|
It turns out that Crystal 11.5 is not compatable with Visual Studio 2008. I need to update to Crystal 2008.
|
|
|
|
|
Hello to everybody, i hope you can help me, I have a dataset which contains datas from a table..this table has 2 fields (id and data) both are string, well i want to do this:
i need to get all the datas from every id and save them into an array, i need this for every id...
Note: the id may be repeated according to the number of datas that contains that id.....for example:
...........................................................................
This is what my dataset contains
ID DATA
-------- ----
04231050 368 ...here you can see that the id is repeated
04231050 234 ...
04333333 445 ......other id repeated
04333333 557 ......
04235789 786
...........................................................................
But I want it like this:
ID DATA DATA
-------- ---- ----
04231050 368 234
04333333 445 557
04235789 786
modified on Monday, April 6, 2009 2:10 PM
|
|
|
|
|
Not really related to Asp.Net.
I recommend you to repost your question in the appropriate forum to enhance the chance to get a proper answer.
But until then you can read up on Jagged Arrays here[^] or here[^] depending on your lingual taste.
"Lots of programmers have had sex - some have even had it with members of the same species." - Pete O'Hanlon
|
|
|
|
|
put your dataset Table in to dataview and then
convert it back to table with distinct values and then covert datatable to array
as follow
C#
[code]
DataView dv=new DataView(ds.Tables["tblName"]);
DataTable temp=dv.ToTable(true,"col1","col2");
[/code]
now convert temp to array
|
|
|
|
|
Hi all,
i am kind new to ASP.NET, developing a asp.net web app with VS.NET2008 and C#.
I try to follow this tutorial:
http://www.fmsinc.com/FRee/NewTips/NET/NETtip35.asp[^]
, but it seems to be based on win32 code or something because on my web forms i cant find the same events, properties, etc. So i am traslating that code to the following:
Item = Row
grid_ItemCommand = grid_RowCommand
onmouseenter = onmouseover
onmouseleave = onmouseout, etc.
But still can't make it work on my GridView control.
Can anyone help me?
my code right now is:
protected void gvUsuarios_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
gvUsuarios.SelectedIndex = ((GridViewRow)sender).RowIndex;
}
}
protected void gvUsuarios_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (gvUsuarios.SelectedIndex > -1)
{
GridViewRow gvr = ((System.Web.UI.WebControls.GridView)sender).Rows[gvUsuarios.SelectedIndex];
if (gvr.RowType == DataControlRowType.DataRow)
{
LinkButton button = (LinkButton)gvUsuarios.Rows[gvUsuarios.SelectedIndex].Cells[1].Controls[1];
if (button != null)
{
((GridView)sender).Attributes["ondblclick"] = ClientScript.GetPostBackClientHyperlink(button, "");
}
((GridViewRow)sender).Attributes.Add("onmouseover", "highlightRow(this, '" + ColorTranslator.ToHtml(gvUsuarios.SelectedRowStyle.BackColor) + "')");
((GridViewRow)sender).Attributes.Add("onmouseout", "dehighlightRow(this, '" + ColorTranslator.ToHtml(gvUsuarios.RowStyle.BackColor) + "')");
}
}
}
<pre>
Thanks a lot!
|
|
|
|
|
It seems to me that you have exchanged the DataGrid in the article for a GridView.
Datagrids still works in later versions of visual studio. It just isn't drag'n'drop.
"Lots of programmers have had sex - some have even had it with members of the same species." - Pete O'Hanlon
|
|
|
|
|
Thanks for the tip.
Meanwhile i found the way. Here is my code if anyone is curious about it:
protected void gvUsuarios_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
GridViewRow gvr = ((GridViewRow)((LinkButton)((GridViewCommandEventArgs)e).CommandSource).Parent.Parent);
gvUsuarios.SelectedIndex = gvr.RowIndex;
}
}
protected void gvUsuarios_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow gvr = ((GridViewRowEventArgs)e).Row;
if (gvr.RowType == DataControlRowType.DataRow)
{
if (gvUsuarios.EditIndex < 0)
{
LinkButton button = (LinkButton)gvr.Cells[1].Controls[1];
if (button != null)
{
gvr.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(button, "");
}
}
if (gvr.RowIndex == gvUsuarios.SelectedIndex)
{
gvr.Attributes.Add("onmouseover", "highlightRow(this, '#B0FF62')");
gvr.Attributes.Add("onmouseout", "dehighlightRow(this, '" + ColorTranslator.ToHtml(gvUsuarios.SelectedRowStyle.BackColor) + "')");
}
else
{
gvr.Attributes.Add("onmouseover", "highlightRow(this, '" + ColorTranslator.ToHtml(Color.White) + "')");
gvr.Attributes.Add("onmouseout", "dehighlightRow(this, '" + ColorTranslator.ToHtml(gvUsuarios.RowStyle.BackColor) + "')");
}
}
}
|
|
|
|
|
Hi,
I have searched for an example of an ASP.NET web site project which would serve as a good starter for any number of web applications.
I need to create a web site which manages a load of stock for someone and the first thing I have to do is build a website with a few users who have various roles, etc. I will need to create a login form, a password retrieval form, and so on.
Does anyone know of an article or example which provides this as a project I can just download and start working with, adding my own code as I need to rather than having to repeat a load of work which has already been done?
I think it would be great for Visual Studio to have a wizard to just build and configure a web site complete with membership, security and roles built in. Then we programmers could just get on with the non-bolierplate stuff.
|
|
|
|
|
|
Hi,
In my application, I enter a string as "Show Names" in a text field which is in updatepanel. This string is stored in database. later on another page this string is used to populate the column header. The column header displays properly as
Show
Names
with break after the string "Show".
now I go back to previous page where it loads the values saved in database. There is a check box in the same update panel , clicking on it causes a postback. But then it causes a server error with code 500. It is caused by string in the text field. At any cost I need this line break for the column header from the saved column header string.
How to resolve this issue?
Thanks
kMeena
|
|
|
|
|
meenakumar wrote: error with code 500.
This is not helpful. You need to debug your code and see where it is breaking. Also uncheck "Show Friendly error" in the tools->Internet Options-> advanced menu, if you are running IE. that may be give you a better error.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Hi
i am in requirement where i need to access dropdownlist in footer of gridview from javascript. and find items in dropdownlist, depending on condition i need to add/remove items from the list.
Could somebody help me please...........
Thanks in advance
Naina
|
|
|
|
|
Please can you post code. A little bit ambiguous
|
|
|
|
|
Thanks for the reply.
I have a gridview as below
<asp:gridview id="grdv" runat="server" showfooter="true" xmlns:asp="#unknown">
<columns> <templatefield>
<edititemtemplate>
dropdownlist
dropdownlist
now i want to access the dropdownlist and its values present in edititemtemplate and footer of gridview from javascript. Also i want to add/remove the values from dropdownlist.
Thanks
Naina
|
|
|
|
|
Are you constrained to using Javascript? Otherwise, it's easy to access the template control from codebehind using the FindControl function. What are you trying to achieve? Again I think we need more code than you've provided for us to adequately help you.
|
|
|
|
|
Hi, I've designed a templated ASP.NET GridView Control. What I want to achieve is to change the HeaderText of one of the columns based on a DropDownList SelectedIndexChanged event. I placed a label into the HeaderTemplate:
<headertemplate>
<asp:label id="lblValueRate" runat="server" width="64px" xmlns:asp="#unknown">""
If a User selects 'Value' from the dropdownlist then I set the Text property of lblValueRate to 'Value' and if User selects 'Rate', changes to 'Rate'.
<asp:dropdownlist id="dbcValueRate" runat="server" autopostback="True" xmlns:asp="#unknown">
<asp:listitem>Rate <asp:listitem>Value
I've tried implementing it this way without success:
Label lblNew = (Label)GridView1.HeaderRow.FindControl("lblValueRate");
Then set lblNew.Text = Rate or Value
This didn't change the GridView Column Header so I thought perhaps I wasn't getting a reference to lblValueRate. So I tried using pointer in unsafe code, Like this:
Label* ptrLabel = &((Label)GridView1.HeaderRow.FindControl("lblValueRate"));
and dereferenced it this way: Label lblNew = *(ptrLabel);
But throws up error that can't get address of managed control.
I believe this is very trivial, but I seem stuck here. Thanks!
|
|
|
|
|
Yeah, I've solved the issue. The code works as it is. Made a few mix-ups elsewhere in code. It's interesting that the assignment,
Label lblNew = (Label)GridView1.HeaderRow.FindControl("lblValueRate");
copies the address as well, rather than just the value as we have, when we copy one variable to another? It was this consideration that made me consider using pointers as an alternative - thankfully, .NET does the 'dirty work' for you. Or so it seems.
Thanks everyone!
|
|
|
|
|
Hi,
I m using asp.net 2008 (framework 3.5) with Ajax. I have a requirement where i want to open modal pop up on selection of either yes/no from radio buttons.
Targetcontrolid of modal pop up extender is id of selected radiobutton. Although it opens the modal pop up but it does not retain the selected value of radio button.
I m also using update panel here to prevent postback but still it does not work.
If anyone can tell me what i m missing here.
|
|
|
|
|
I m using asp.net 2008 (framework 3.5) with Ajax. I have a requirement where i want to open modal pop up on selection of either yes/no from radio buttons.
Targetcontrolid of modal pop up extender is id of selected radiobuttonlist. Although it opens the modal pop up but it does not retain the selected value of radio button.
can anyone help
|
|
|
|