|
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
|
|
|
|
|
i have one usercontrol and that control i want to add user control in page using
fck editor.
i mean that i am adding the code <uc:control id=""> in fckeditor.
when i retrive that(fckeditor page) page in front i want to show the
user control.
regards
keyur satyadev
|
|
|
|
|
fckeditor is just an editor. You can use whatever editor your feel comfortable with.
I guess what you are looking for is User Controls[^].
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[^]
|
|
|
|
|
I have several TextBox controls with initial values. When I tab between them, the OnFocus event blanks out the initial value by setting value="". When this happens, the caret disappears. This gives the user the impression that the control has lost focus, but it hasn't. This does not happen if you click in any of the TextBoxes with the mouse, only when tabbing into a TextBox. Any ideas?
|
|
|
|
|
Hello Everybody
I am using asp calendar control on my web page but its big according to the page i have set its width and height but its not resizing..
Thanks.
|
|
|
|
|
I guess this thing happens because the size of div or table is large where you put this calendar control..
so first of all checkout size of that where your control is...
if i am not right then give some description or code..
thanks..
|
|
|
|
|
Thanks for reply
i have checked that out its not matter if i am using only calendar control on whole page then also the same problem after setting height and width its size is not changing..
|
|
|
|
|
Can you please send the code..so i can understand it..
Because it works fine at my side..
|
|
|
|
|
i am able to make it big but not able to make it small in size.
<asp:calendar id="cal" runat="server" height="10px" width="12px" xmlns:asp="#unknown">
thanks.
|
|
|
|
|
thanks for reply
its done first we have set its all day and header style then we will be able to..actually i needed it urgent..
|
|
|
|