Child Grid View's OnRowCommand not fired in Nested Grid View criteria - c#-3.0

i m working with nested grid view scenario. how ever i found that my Child grid view's OnRowCommand not fired inside Parent grid view. i surfing and found one solution like.
After implementing this i have no effect. still my child grid view OnRowCommand not fired
for more information i place my code:
protected void GV_ViewServices_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header && this.ViewState["SortExp"] != null)
{
System.Web.UI.WebControls.Image ImgSort = new System.Web.UI.WebControls.Image();
if (this.ViewState["SortOrder"].Equals("ASC"))
ImgSort.ImageUrl = "../images/down_arrow_1.gif";
else
ImgSort.ImageUrl = "~/images/up_arrow_1.gif";
switch (this.ViewState["SortExp"].ToString())
{
case "Service_name":
PlaceHolder placeholderServiceName = (PlaceHolder)e.Row.FindControl("placeholderServiceName");
placeholderServiceName.Controls.Add(ImgSort);
break;
case "IsActive":
PlaceHolder placeholderstatus = (PlaceHolder)e.Row.FindControl("placeholderstatus");
placeholderstatus.Controls.Add(ImgSort);
break;
case "Service_desc":
PlaceHolder placeholderdescription = (PlaceHolder)e.Row.FindControl("placeholderdescription");
placeholderdescription.Controls.Add(ImgSort);
break;
case "Created_date":
PlaceHolder placeholderdate = (PlaceHolder)e.Row.FindControl("placeholderdate");
placeholderdate.Controls.Add(ImgSort);
break;
}
}
else if (e.Row.RowType == DataControlRowType.DataRow)
{
System.Web.UI.WebControls.GridView GV_ViewServiceFeature = (System.Web.UI.WebControls.GridView)e.Row.FindControl("GV_ViewServiceFeature");
if (Session["ChildPageIndex"] != null)
{
DataTable dtPageIndex = (DataTable)Session["ChildPageIndex"];
GV_ViewServiceFeature.PageIndex = Convert.ToInt16(dtPageIndex.Rows[e.Row.RowIndex][0]);
}
FillFeatureGrid(int.Parse(GV_ViewServices.DataKeys[e.Row.RowIndex].Value.ToString()), GV_ViewServiceFeature);
System.Web.UI.WebControls.GridView GV_ViewServiceCharge = (System.Web.UI.WebControls.GridView)e.Row.FindControl("GV_ViewServiceCharge");
if (Session["ChildPageIndex"] != null)
{
DataTable dtPageIndex = (DataTable)Session["ChildPageIndex"];
GV_ViewServiceCharge.PageIndex = Convert.ToInt16(dtPageIndex.Rows[e.Row.RowIndex][0]);
}
FillChargeGrid(int.Parse(GV_ViewServices.DataKeys[e.Row.RowIndex].Value.ToString()), GV_ViewServiceCharge);
}
}
protected void GV_ViewServiceFeature_RowCommand(object sender, GridViewCommandEventArgs e)
{
foreach(GridViewRow row in GV_ViewServices.Rows)
{
GridView gv=row.FindControl("GV_ViewServiceFeature") as GridView;
if (e.CommandName.Equals("AddNew") && Page.IsValid)
{
TextBox txtfeaturetext = (TextBox)gv.FooterRow.FindControl("txtfeaturetext");
int returnValue = DatabaseHelper.AddNewServiceFeature(int.Parse(service_id.Value.ToString()), txtfeaturetext.Text.Trim());
if (returnValue > 0)
{
this.FillFeatureGrid(int.Parse(GV_ViewServices.DataKeys[row.RowIndex].Value.ToString()),gv);
}
}
int intCurIndex = gv.PageIndex;
switch (e.CommandArgument.ToString().ToLower())
{
case "first":
gv.PageIndex = 0;
break;
case "prev":
CurrentPage -= 1;
break;
case "next":
CurrentPage += 1;
break;
case "last":
gv.PageIndex = gv.PageCount;
break;
}
this.FillFeatureGrid(int.Parse(GV_ViewServices.DataKeys[row.RowIndex].Value.ToString()), gv);
}
}
please help me out this problem.

first off all we have to manually register command at Parent grid view row_created event.
protected void GV_ViewServices_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv = e.Row.FindControl("GV_ViewServiceFeature") as GridView;
gv.RowCommand += new GridViewCommandEventHandler(GV_ViewServiceFeature_RowCommand);
GridView gv1 = e.Row.FindControl("GV_ViewServiceCharge") as GridView;
gv1.RowCommand += new GridViewCommandEventHandler(GV_ViewServiceCharge_RowCommand);
}
}
protected void GV_ViewServiceFeature_RowCommand(object sender, GridViewCommandEventArgs e)
{
System.Web.UI.WebControls.GridView gv = ((System.Web.UI.WebControls.GridView)sender);
GridViewRow gvRowParent = ((System.Web.UI.WebControls.GridView)sender).Parent.Parent.Parent.Parent as GridViewRow;
if (e.CommandName.Equals("AddNew"))
{
Page.Validate("AddNewFeature");
TextBox txtfeaturetext = (TextBox)gv.FooterRow.FindControl("txtfeaturetext");
int returnValue = DatabaseHelper.AddNewServiceFeature(int.Parse(GV_ViewServices.DataKeys[gvRowParent.RowIndex].Value.ToString()), txtfeaturetext.Text.Trim());
if (returnValue > 0)
{
this.FillFeatureGrid(int.Parse(GV_ViewServices.DataKeys[gvRowParent.RowIndex].Value.ToString()), gv);
}
}
int intCurIndex = gv.PageIndex;
switch (e.CommandArgument.ToString().ToLower())
{
case "first":
gv.PageIndex = 0;
break;
case "prev":
CurrentPage -= 1;
break;
case "next":
CurrentPage += 1;
break;
case "last":
gv.PageIndex = gv.PageCount;
break;
}
this.FillFeatureGrid(int.Parse(GV_ViewServices.DataKeys[gvRowParent.RowIndex].Value.ToString()),gv);
}

Related

Incompatible Types: T cannot be converted to LinkedList<T>.Node, confused about how to fix

I'm trying to implement a remove method from scratched for the LinkedList class and like the title says, I've been getting the :
"incompatible types: T cannot be converted to LinkedList.Node"
Here's my code :
public class LinkedList<T> implements LinkedListInterface<T> {
private Node head;
private Node tail;
private int count;
public LinkedList () {
head = null;
tail = null;
count = 0;
}
class Node {
T data;
Node next;
Node(T data) {
this.data = data;
next = null;
}
}
public Node getHead() {
return head;
}
public T remove(int pos) throws ListException {
if (pos < 1 || pos > count) {
throw new ListException("Invalid position to remove from");
}
Node removedItem = null;
if (count == 1) {
removedItem = head.data; // Here it says the error
head = null;
tail = null;
}
else if (pos == 1) {
removedItem = head.data;
head = head.next;
}
else if (pos == count) {
removedItem = tail.data; // Same error
Node prev = jump(pos - 2);
prev.next = null;
tail = prev;
}
else {
Node prev = jump(pos - 2);
removedItem = prev.next.data; // Same error
prev.next = prev.next.next;
}
count--;
return removedItem; // Same error
}
}
I've been so confused on how to fix it, I tried putting this.head.data or this.tail.data but to no avail, any ideas? Thanks

To clear the display after result when input is loaded again

Here after the result is loaded and try to input the next input it just get appended with the result, but the display should be cleared for the second calculation. Any help will be appreciated.
var arr=[];
var input=0;
function numberBtn(arg){
if ( document.getElementById("currentValue").innerHTML ==="ERROR" || (document.getElementById("currentValue").innerHTML == "0"))
{
document.getElementById("currentValue").innerHTML = "";
}
input += arg;
document.getElementById("currentValue").innerHTML += arg;
}
function calculate(val){
if(input !== 0){
addToArr(input);
}
var answer = val[0];
var divideZero =0;
var i=2
switch(arr[i-1]){
case '+':
answer= Number(val[i-2]) + Number(val[i]);
break;
case '-':
answer-= val[i];
break;
case '/':
if (val[i] == 0) divideZero = 1;
else answer = answer / val[i];
break;
case'*':
//console.log(value,'before multiply');
answer = answer * val[i];
// console.log(val[i],'after multiply');
break;
case'%':
if (val[i] == 0) divideZero = 1;
else{
var q= val[i-2]/val[i];
answer= val[i-2] - (val[i] * Math.floor(q));
}
break;
case'+/-':
answer= -answer;
break;
}
if ( divideZero === 1) {
clearAll();
document.getElementById("currentValue").innerHTML = "ERROR";
}
else
{
document.getElementById("currentValue").innerHTML = answer;
input = answer;
arr = [];
}
}
function addToArr(input){
arr.push(input);
}
function clearAll() {
arr = [];
input = 0;
document.getElementById("currentValue").innerHTML = "0";
}
function operatorBtn(arg){
if (input !== 0) {
addToArr(input);
addToArr(arg);
document.getElementById("currentValue").innerHTML +=arg;
input = 0;
}
}

video overwriting using ffmpeg - I want to Add video rotation code and rewrite the existing file..How can i do that?

I want to rotate the .mov file which is in portrait mode by 90 degrees, for that i used the following code..
It works but, it results in loss of video frames...
My code is,
public void encode(File source, File target, EncodingAttributes attributes,
EncoderProgressListener listener, Integer i) throws IllegalArgumentException,
InputFormatException, EncoderException {
String formatAttribute = attributes.getFormat();
Float offsetAttribute = attributes.getOffset();
Float durationAttribute = attributes.getDuration();
QualityScale qualityScale = attributes.getQualityScale();
AudioAttributes audioAttributes = attributes.getAudioAttributes();
VideoAttributes videoAttributes = attributes.getVideoAttributes();
if (audioAttributes == null && videoAttributes == null) {
throw new IllegalArgumentException(
"Both audio and video attributes are null");
}
target = target.getAbsoluteFile();
target.getParentFile().mkdirs();
FFMPEGExecutor ffmpeg = locator.createExecutor();
if (offsetAttribute != null) {
ffmpeg.addArgument("-ss");
ffmpeg.addArgument(String.valueOf(offsetAttribute.floatValue()));
}
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
if (durationAttribute != null) {
ffmpeg.addArgument("-t");
ffmpeg.addArgument(String.valueOf(durationAttribute.floatValue()));
}
if (qualityScale != null) {
ffmpeg.addArgument("-qscale:"+qualityScale.getQualityStreamSpecifier());
ffmpeg.addArgument(String.valueOf(qualityScale.getQualityValue()));
}
if (videoAttributes == null) {
ffmpeg.addArgument("-vn");
} else {
String codec = videoAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-vcodec");
ffmpeg.addArgument(codec);
}
String tag = videoAttributes.getTag();
if (tag != null) {
ffmpeg.addArgument("-vtag");
ffmpeg.addArgument(tag);
}
Integer bitRate = videoAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-b");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer frameRate = videoAttributes.getFrameRate();
if (frameRate != null) {
ffmpeg.addArgument("-r");
ffmpeg.addArgument(String.valueOf(frameRate.intValue()));
}
VideoSize size = videoAttributes.getSize();
if (size != null) {
ffmpeg.addArgument("-s");
ffmpeg.addArgument(String.valueOf(size.getWidth()) + "x"
+ String.valueOf(size.getHeight()));
}
FilterGraph filterGraph = videoAttributes.getFilterGraph();
if (filterGraph != null) {
ffmpeg.addArgument("-vf");
if(videoAttributes.getRotate() != null && videoAttributes.getRotate() == 90){
ffmpeg.addArgument("transpose=1");
}else if(videoAttributes.getRotate() != null && videoAttributes.getRotate() == 180){
ffmpeg.addArgument("vflip,hflip");
}
else {
if (filterGraph.isUseExpression()) {
ffmpeg.addArgument(filterGraph.getFilterGraphExpression());
}
}
}
}
if (audioAttributes == null) {
ffmpeg.addArgument("-an");
} else {
String codec = audioAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-acodec");
ffmpeg.addArgument(codec);
}
Integer bitRate = audioAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-ab");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer channels = audioAttributes.getChannels();
if (channels != null) {
ffmpeg.addArgument("-ac");
ffmpeg.addArgument(String.valueOf(channels.intValue()));
}
Integer samplingRate = audioAttributes.getSamplingRate();
if (samplingRate != null) {
ffmpeg.addArgument("-ar");
ffmpeg.addArgument(String.valueOf(samplingRate.intValue()));
}
Integer volume = audioAttributes.getVolume();
if (volume != null) {
ffmpeg.addArgument("-vol");
ffmpeg.addArgument(String.valueOf(volume.intValue()));
}
}
ffmpeg.addArgument("-f");
ffmpeg.addArgument(formatAttribute);
ffmpeg.addArgument("-y");
ffmpeg.addArgument(target.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
String lastWarning = null;
long duration;
long progress = 0;
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
MultimediaInfo info = parseMultimediaInfo(source, reader);
if (durationAttribute != null) {
duration = (long) Math
.round((durationAttribute.floatValue() * 1000L));
} else {
duration = info.getDuration();
if (offsetAttribute != null) {
duration -= (long) Math
.round((offsetAttribute.floatValue() * 1000L));
}
}
if (listener != null) {
listener.sourceInfo(info);
}
int step = 0;
String line;
while ((line = reader.readLine()) != null) {
System.out.println("line::::"+line);
if (step == 0) {
if (line.startsWith("WARNING: ")) {
if (listener != null) {
listener.message(line);
}
} else if (!line.startsWith("Output #0")) {
//throw new EncoderException(line);
} else {
step++;
}
} else if (step == 1) {
if (!line.startsWith(" ")) {
step++;
} else {
System.out.println("line>>>>>>"+line);
Hashtable table1 = new Hashtable();
Matcher m = ROTATE_INFO_PATTERN.matcher(line);
while (m.find()) {
if (table1 == null) {
table1 = new Hashtable();
}
String key = m.group(1);
String value = m.group(2);
table1.put(key, value);
}
System.out.println("Table values"+table1.get("rotate"));
if(table1.get("rotate") != null){
Object videoRotateValue = table1.get("rotate");
int rotate = Integer.valueOf(videoRotateValue.toString());
switch(rotate){
case 90:
videoAttributes.setRotate(rotate);
if(i == 0){
i++;
encode(source, target, attributes, null, i);
}
break;
case 180:
videoAttributes.setRotate(rotate);
if(i == 0){
i++;
encode(source, target, attributes, null, i);
}
break;
case 270: System.out.println("case 3 :: "+videoRotateValue);
break;
}
}
}
}
if (step == 2) {
if (!line.startsWith("Stream mapping:")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 3) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 4) {
line = line.trim();
if (line.length() > 0) {
Hashtable table = parseProgressInfoLine(line);
if (table == null) {
if (listener != null) {
listener.message(line);
}
lastWarning = line;
} else {
if (listener != null) {
String time = (String) table.get("time");
if (time != null) {
int dot = time.indexOf('.');
if (dot > 0 && dot == time.length() - 2
&& duration > 0) {
String p1 = time.substring(0, dot);
String p2 = time.substring(dot + 1);
try {
long i1 = Long.parseLong(p1);
long i2 = Long.parseLong(p2);
progress = (i1 * 1000L)
+ (i2 * 100L);
int perm = (int) Math
.round((double) (progress * 1000L)
/ (double) duration);
if (perm > 1000) {
perm = 1000;
}
listener.progress(perm);
} catch (NumberFormatException e) {
;
}
}
}
}
lastWarning = null;
}
}
}
}
if (lastWarning != null) {
if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) {
throw new EncoderException(lastWarning);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
ffmpeg.destroy();
}
}
Please advise, how to achieve video rotation without any video Frame loss
Thanks In Advance
Lakshmi Priya . K
Worked for couple of days and finally tried to write the rotated video in different target file then i got the video output without any loss and video is also rotated....
Thanks
Lakshmi Priya. K

Change label's text with using property

I am working on my C# ADO.NET app. I have connected my SQL Server database with C# app, and I can perform simple CRUD operations. I want to make that my app open my reminder form when someone in my database have birthday, so I made my query and all persons who have birthday on today's day are in my query, and with using property from my reminder form I change label's text with name and surname of person who have birthday. Now I just dont know how to change next label's text when more than one person have birthday in my query... I dont know how to get next element in my foreach loop...
Here is my code:
Form2 forma = new Form2();
TBirthDayEntities today_born = new TBirthDayEntities();
public Form1()
{
InitializeComponent();
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Interval = 1000;
timer1.Enabled = true;
timer1.Start();
}
private Boolean provjera_rodj()
{
Boolean flag = false;
int cnt = 0;
IQueryable<TBD> query;
using (var data = new TBirthDayEntities())
{
query = (from x in data.TBD
where x.BirthDay.Day == System.DateTime.Now.Day && x.BirthDay.Month == System.DateTime.Now.Month
select x);
foreach (var x in query)
{
today_born.TBD.Add(x);
cnt += 1;
flag = true;
}
}
switch (cnt)
{
case 1:
{
foreach (var x in today_born.TBD)
{
forma.p_label2 = x.FName + " " + x.LName;
}
break;
}
case 2:
{
foreach (var x in today_born.TBD)
{
forma.p_label2 = x.FName + x.LName;
forma.p_label3 = x.FName + x.LName; //wrong
}
break;
}
}
return flag;
}
private void timer1_Tick(object sender, EventArgs e)
{
Boolean flag = provjera_rodj();
if (flag == true)
{
forma.Show();
timer1.Stop();
}
}
switch (cnt)
{
case 1:
case 2:
{
var lstLabel = new List<Label>()
{
forma.p_label2
, forma.p_label3
};
for(int i = 0; i < today_born.TBD.Count; i++)
{
var x in today_born.TBD[i];
lstLabel[x].Text = x.FName + x.LName;
}
break;
}
}
EDIT:
switch (cnt)
{
case 1:
case 2:
{
var lstLabel = new List<Action<string>>()
{
new Action<string>(s =>forma.p_label2 = s)
, new Action<string>(s =>forma.p_label3 = s)
};
for(int i = 0; i < today_born.TBD.Count; i++)
{
var x = today_born.TBD[i];
lstLabel[x](x.FName + x.LName);
}
break;
}
}

TypeError: 'undefined' is not a function (evaluating 'ime.registIMEKey()')

Despite of setting and defining everything in Samsung smart TV SDK 4.0 I am getting this error:
TypeError: 'undefined' is not a function (evaluating 'ime.registIMEKey()')
Please help!
CODE:
var widgetAPI = new Common.API.Widget();
var tvKey = new Common.API.TVKeyValue();
var wapal_magic =
{
elementIds: new Array(),
inputs: new Array(),
ready: new Array()
};
/////////////////////////
var Input = function (id, previousId, nextId) {
var previousElement = document.getElementById(previousId),
nextElement = document.getElementById(nextId);
var installFocusKeyCallbacks = function () {
ime.setKeyFunc(tvKey.KEY_UP, function (keyCode) {
previousElement.focus();
return false;
});
ime.setKeyFunc(tvKey.KEY_DOWN, function (keyCode) {
nextElement.focus();
return false;
});
ime.setKeyFunc(tvKey.KEY_RETURN, function (keyCode) {
widgetAPI.blockNavigation();
return false;
});
ime.setKeyFunc(tvKey.KEY_EXIT, function (keyCode) {
widgetAPI.blockNavigation();
return false;
});
}
var imeReady = function (imeObject) {
installFocusKeyCallbacks();
wapal_magic.ready(id);
},
ime = new IMEShell(id, imeReady, 'en'),
element = document.getElementById(id);
}
wapal_magic.createInputObjects = function () {
var index,
previousIndex,
nextIndex;
for (index in this.elementIds) {
previousIndex = index - 1;
if (previousIndex < 0) {
previousIndex = wapal_magic.inputs.length - 1;
}
nextIndex = (index + 1) % wapal_magic.inputs.length;
wapal_magic.inputs[index] = new Input(this.elementIds[index],
this.elementIds[previousIndex], this.elementIds[nextIndex]);
}
};
wapal_magic.ready = function (id) {
var ready = true,
i;
for (i in wapal_magic.elementIds) {
if (wapal_magic.elementIds[i] == id) {
wapal_magic.ready[i] = true;
}
if (wapal_magic.ready[i] == false) {
ready = false;
}
}
if (ready) {
document.getElementById("txtInp1").focus();
}
};
////////////////////////
wapal_magic.onLoad = function()
{
// Enable key event processing
//this.enableKeys();
// widgetAPI.sendReadyEvent();
this.initTextBoxes(new Array("txtInp1", "txtInp2"));
};
wapal_magic.initTextBoxes = function(textboxes){
this.elementIds = textboxes;
for(i=0;i<this.elementIds.length;i++){
this.inputs[i]=false;
this.ready[i]=null;
}
this.createInputObjects();
widgetAPI.registIMEKey();
};
wapal_magic.onUnload = function()
{
};
wapal_magic.enableKeys = function()
{
document.getElementById("anchor").focus();
};
wapal_magic.keyDown = function()
{
var keyCode = event.keyCode;
alert("Key pressed: " + keyCode);
switch(keyCode)
{
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN:
alert("RETURN");
widgetAPI.sendReturnEvent();
break;
case tvKey.KEY_LEFT:
alert("LEFT");
break;
case tvKey.KEY_RIGHT:
alert("RIGHT");
break;
case tvKey.KEY_UP:
alert("UP");
break;
case tvKey.KEY_DOWN:
alert("DOWN");
break;
case tvKey.KEY_ENTER:
case tvKey.KEY_PANEL_ENTER:
alert("ENTER");
break;
default:
alert("Unhandled key");
break;
}
};
The registIMEKey method is part of the Plugin API.
var pluginAPI = new Common.API.Plugin();
pluginAPI.registIMEKey();
See: http://www.samsungdforum.com/Guide/ref00006/common_module_plugin_object.html#ref00006-common-module-plugin-object-registimekey
Edit: Updated to add code solution.
widgetAPI no contains method registIMEKey();, it contains in IMEShell.